Closed Parsifa1 closed 7 months ago
I know the problem, close lazyload
Oh, there is another problem. In the workspace opened in this way, the lsp of the corresponding file cannot be attached. like this:
File type not detected
Sorry I didn't get around to replying yesterday. Did you resolve the issue?
Yes! Your plugin is very light and easy to use. I replaced the plugin that handles sessions with another one and it works very smoothly! Thank you for yout work🥰
Have just hit the second issue myself with a potential fix :)
According to Justin, the auto command needs to be nested and surely enough with the below lazy recipe all works as expected vs setting auto_open
.
{
"natecraddock/workspaces.nvim",
init = function()
vim.api.nvim_create_autocmd({ "VimEnter" }, {
pattern = "*",
nested = true,
callback = function()
for _, workspace in pairs(require("workspaces").get()) do
-- dont autoload if nvim start with arg
if vim.fn.argc(-1) > 0 then
return
end
if workspace.path == vim.fn.fnamemodify(vim.fn.getcwd(), ":p") then
require("workspaces").open(workspace.name)
end
end
end,
})
end,
opts = {
cd_type = "local",
hooks = {
open_pre = {
-- If recording, save current session state and stop recording
"SessionsStop",
-- delete all buffers (does not save changes)
":Bdelete!",
},
open = function()
require("sessions").load(nil, { silent = true })
end,
},
},
}
Happy to PR the tiny fix @natecraddock, thanks for a lovely set of plugins :)
EDIT:
Also with that PR now checked out, auto_open
works as intended!
I couldn't find the error in this function, but it didn't work properly on my device. When I entered nvim on the path of the existing Workspace, it couldn't automatically load the session:
and this is my config:
As an aside, is it possible to add feature that automatically stop session recording when my current working directory is no longer the working path I set? Thank you very much. Your plug-in is very light and easy to use.