From 2d122d4cb47cf0502d85d991b0391635d0437e5a Mon Sep 17 00:00:00 2001 From: Siddhartha Menon <42359201+Sqvid@users.noreply.github.com> Date: Tue, 1 Aug 2023 16:04:40 +0100 Subject: [PATCH] Make session file hidden. Dont restore for git. --- neovim/.config/nvim/lua/autocmds.lua | 18 ++++++++++++------ neovim/.config/nvim/lua/mappings.lua | 2 -- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/neovim/.config/nvim/lua/autocmds.lua b/neovim/.config/nvim/lua/autocmds.lua index 28d24d3..12143ce 100644 --- a/neovim/.config/nvim/lua/autocmds.lua +++ b/neovim/.config/nvim/lua/autocmds.lua @@ -65,10 +65,16 @@ autocmd("VimEnter", { nested = true, callback = function () + -- Can eventually extend the list of exception filetypes using a table + -- or regex. + if vim.bo.filetype == "gitcommit" then + return + end + local cwd = func.getcwd() - local session = cwd .. "/Session.vim" + local sessionfile = cwd .. "/.Session.vim" - if func.filereadable(session) ~= 0 then + if func.filereadable(sessionfile) == 1 then vim.ui.input( { prompt = "Detected session file. Restore it? (y/n): " @@ -76,7 +82,7 @@ autocmd("VimEnter", { function(input) if input == "y" then - cmd("so ".. session) + cmd("source ".. sessionfile) vim.g.LoadedFromSession = true end end @@ -89,10 +95,10 @@ autocmd("VimLeave", { callback = function () local cwd = func.getcwd() - local session = cwd .. "/Session.vim" + local sessionfile = cwd .. "/.Session.vim" - if vim.g.LoadedFromSession and func.filewritable(session) == 0 then - cmd("mksession!") + if vim.g.LoadedFromSession and func.filewritable(sessionfile) == 1 then + cmd("mksession! " .. sessionfile) end end }) diff --git a/neovim/.config/nvim/lua/mappings.lua b/neovim/.config/nvim/lua/mappings.lua index 95eea01..d124a7d 100644 --- a/neovim/.config/nvim/lua/mappings.lua +++ b/neovim/.config/nvim/lua/mappings.lua @@ -14,8 +14,6 @@ map("n", "gb", "gT", mapOpts) map("n", "", ":Texplore", mapOpts) map("n", "[b", ":bprevious", mapOpts) map("n", "]b", ":bnext", mapOpts) --- Commonly mistyped quit. -map("n", "q:", ":q") -- Insert-mode mappings map("i", ",,", "", mapOpts)