auto_load_trailblazer_state_on_enter without automatically opening buffer? #51
-
Hi! I'm starting to like this plugin a lot. I've activated |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Ok, I managed to fix this by patching trailblazer's function I haven't battle-tested this but works fine for now.
return {
"LeonHeidelbach/trailblazer.nvim",
lazy = true,
dependencies = "nvim-treesitter/nvim-treesitter",
opts = {
auto_save_trailblazer_state_on_exit = false, -- we are manually doing it on resession.nvim
auto_load_trailblazer_state_on_enter = false, -- we are manually doing it on resession.nvim
...
}
return {
"stevearc/resession.nvim",
dependencies = "LeonHeidelbach/trailblazer.nvim",
config = function(_, opts)
local resession = require("resession")
local trailblazer = require("trailblazer")
local trailblazer_common = require("trailblazer.trails.common")
local focus_win_and_buf = trailblazer_common.focus_win_and_buf
resession.setup(opts)
resession.add_hook("pre_load", function()
---Patch trailblazer
trailblazer_common.focus_win_and_buf = function() return true end
end)
resession.add_hook("post_load", function()
trailblazer.load_trailblazer_state_from_file()
---Unpatch trailblazer
vim.schedule(function() trailblazer_common.focus_win_and_buf = focus_win_and_buf end)
end)
...
vim.api.nvim_create_autocmd("VimLeavePre", {
desc = "Save a dir-specific session when you close Neovim",
group = vim.api.nvim_create_augroup("autosave_session", { clear = true }),
callback = function()
-- Only save the session if nvim was started with no args
if vim.fn.argc(-1) == 0 then
trailblazer.save_trailblazer_state_to_file()
resession.save_tab(vim.fn.getcwd(), { dir = "dirsession", notify = false })
end
end,
})
end,
... |
Beta Was this translation helpful? Give feedback.
-
@serranomorante I'm glad you like the plugin. I have considered implementing loading buffers on demand, i.e. only when jumping to a specific mark, however this would have required some rather more involved changes to the code base and did also cause several issues when I was experimenting with it. Since I would not use this myself I decided agains implementing this functionality. However, if you would like to work on this and create a PR, feel free to do so and I will review it. If the proposed changes for your specific setup is all you need, that's also fine 👍 . |
Beta Was this translation helpful? Give feedback.
@serranomorante I'm glad you like the plugin. I have considered implementing loading buffers on demand, i.e. only when jumping to a specific mark, however this would have required some rather more involved changes to the code base and did also cause several issues when I was experimenting with it. Since I would not use this myself I decided agains implementing this functionality. However, if you would like to work on this and create a PR, feel free to do so and I will review it. If the proposed changes for your specific setup is all you need, that's also fine 👍 .