dotfiles/.config/nvim/lua/func/sessions.lua
Ben Vincent b1f1ff8545 VIM updates
- updated keybindings to match work
- added functions for finding files
2024-03-11 18:08:32 +11:00

28 lines
891 B
Lua

vim.cmd([[
let g:session_dir = expand('~/.cache/nvim/sessions/')
if !isdirectory(g:session_dir)
call mkdir(g:session_dir, "p")
endif
command! SaveSession call SaveSession()
function! SaveSession()
let session_file = g:session_dir . GetRepositoryName() . '_' . GetCurrentGitBranch() . '.vim'
execute 'mksession! ' . session_file
echo "Session saved to " . session_file
endfunction
command! LoadSession call LoadSession()
function! LoadSession()
let session_file = g:session_dir . GetRepositoryName() . '_' . GetCurrentGitBranch() . '.vim'
if filereadable(session_file)
execute 'source ' . session_file
echo "Session loaded from " . session_file
else
echo "No session found for the current Git branch in the repository"
endif
endfunction
nnoremap <silent> <Leader>ss :SaveSession<CR>
nnoremap <silent> <Leader>sl :LoadSession<CR>
]])