diff --git a/lua/autocmds.lua b/lua/autocmds.lua index d66f1ac..1618e06 100644 --- a/lua/autocmds.lua +++ b/lua/autocmds.lua @@ -106,18 +106,27 @@ local session_aug = vim.api.nvim_create_augroup("SessionManagement", { clear = t vim.api.nvim_create_autocmd("VimEnter", { group = session_aug, pattern = "*", - nested = true, -- Allow other autocmds to fire after loading session + once = true, 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") + vim.cmd("silent! source Session.vim") end end, }) +-- Ensure filetype is detected for current buffer after session load +vim.api.nvim_create_autocmd("SessionLoadPost", { + group = session_aug, + pattern = "*", + callback = function() + vim.cmd("filetype detect") + end, +}) + -- Auto-save session on exit, but ONLY if Session.vim already exists vim.api.nvim_create_autocmd("VimLeavePre", { group = session_aug,