Skip to content

Commit

Permalink
Make session file hidden. Dont restore for git.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sqvid committed Aug 1, 2023
1 parent 831519f commit 2d122d4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
18 changes: 12 additions & 6 deletions neovim/.config/nvim/lua/autocmds.lua
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,24 @@ 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): "
},

function(input)
if input == "y" then
cmd("so ".. session)
cmd("source ".. sessionfile)
vim.g.LoadedFromSession = true
end
end
Expand All @@ -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
})
Expand Down
2 changes: 0 additions & 2 deletions neovim/.config/nvim/lua/mappings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ map("n", "gb", "gT", mapOpts)
map("n", "<C-t>", ":Texplore<CR>", mapOpts)
map("n", "[b", ":bprevious<CR>", mapOpts)
map("n", "]b", ":bnext<CR>", mapOpts)
-- Commonly mistyped quit.
map("n", "q:", ":q<CR>")

-- Insert-mode mappings
map("i", ",,", "<Esc>", mapOpts)

0 comments on commit 2d122d4

Please sign in to comment.