mirror of
https://github.com/dcarrillo/dotfiles.git
synced 2025-07-04 14:39:25 +00:00
[neovim] Move from session_manager to projections
This commit is contained in:
@ -35,3 +35,30 @@ vim.api.nvim_create_autocmd({ "BufWinEnter" }, {
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
-- Autostore session on VimExit
|
||||
local session = require("projections.session")
|
||||
vim.api.nvim_create_autocmd({ "VimLeavePre" }, {
|
||||
callback = function()
|
||||
session.store(vim.loop.cwd())
|
||||
end,
|
||||
})
|
||||
|
||||
-- If vim was started with arguments, do nothing
|
||||
-- If in some project's root, attempt to restore that project's session
|
||||
-- If not, restore last session
|
||||
-- If no sessions, do nothing
|
||||
vim.api.nvim_create_autocmd({ "VimEnter" }, {
|
||||
callback = function()
|
||||
if vim.fn.argc() ~= 0 then
|
||||
return
|
||||
end
|
||||
local session_info = session.info(vim.loop.cwd())
|
||||
if session_info == nil then
|
||||
session.restore_latest()
|
||||
else
|
||||
session.restore(vim.loop.cwd())
|
||||
end
|
||||
end,
|
||||
desc = "Restore last session automatically",
|
||||
})
|
||||
|
Reference in New Issue
Block a user