Update documentation and add session management features
- Revise keymap documentation to include immediate updates - Add session management: auto-load and auto-save Session.vim
This commit is contained in:
parent
c9a7b3b694
commit
82faf75f28
5 changed files with 56 additions and 4 deletions
|
|
@ -99,4 +99,35 @@ vim.api.nvim_create_autocmd("FileType", {
|
|||
end,
|
||||
})
|
||||
|
||||
-- Session management: auto-load on startup, auto-save on exit (only if Session.vim exists)
|
||||
local session_aug = vim.api.nvim_create_augroup("SessionManagement", { clear = true })
|
||||
|
||||
-- Auto-load Session.vim if it exists in the current directory
|
||||
vim.api.nvim_create_autocmd("VimEnter", {
|
||||
group = session_aug,
|
||||
pattern = "*",
|
||||
nested = true, -- Allow other autocmds to fire after loading session
|
||||
callback = function()
|
||||
-- Only auto-load if:
|
||||
-- 1. Session.vim exists in cwd
|
||||
-- 2. No files were specified on command line (vim.fn.argc() == 0)
|
||||
-- 3. Not started with nvim -S (check if we already loaded a session)
|
||||
if vim.fn.argc() == 0 and vim.fn.filereadable("Session.vim") == 1 and vim.v.this_session == "" then
|
||||
vim.cmd("source Session.vim")
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
-- Auto-save session on exit, but ONLY if Session.vim already exists
|
||||
vim.api.nvim_create_autocmd("VimLeavePre", {
|
||||
group = session_aug,
|
||||
pattern = "*",
|
||||
callback = function()
|
||||
-- Only save if Session.vim exists (user manually created it)
|
||||
if vim.fn.filereadable("Session.vim") == 1 then
|
||||
vim.cmd("mksession! Session.vim")
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
return {}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue