diff --git a/neovim/.config/nvim/init.lua b/neovim/.config/nvim/init.lua index bed2a64..224be1d 100644 --- a/neovim/.config/nvim/init.lua +++ b/neovim/.config/nvim/init.lua @@ -1,10 +1,10 @@ -- --- ███╗░░██╗███████╗░█████╗░██╗░░░██╗██╗███╗░░░███╗ --- ████╗░██║██╔════╝██╔══██╗██║░░░██║██║████╗░████║ --- ██╔██╗██║█████╗░░██║░░██║╚██╗░██╔╝██║██╔████╔██║ --- ██║╚████║██╔══╝░░██║░░██║░╚████╔╝░██║██║╚██╔╝██║ --- ██║░╚███║███████╗╚█████╔╝░░╚██╔╝░░██║██║░╚═╝░██║ --- ╚═╝░░╚══╝╚══════╝░╚════╝░░░░╚═╝░░░╚═╝╚═╝░░░░░╚═╝ +-- ███╗ ██╗███████╗ █████╗ ██╗ ██╗██╗███╗ ███╗ +-- ████╗ ██║██╔════╝██╔══██╗██║ ██║██║████╗ ████║ +-- ██╔██╗██║█████╗ ██║ ██║╚██╗ ██╔╝██║██╔████╔██║ +-- ██║╚████║██╔══╝ ██║ ██║ ╚████╔╝ ██║██║╚██╔╝██║ +-- ██║ ╚███║███████╗╚█████╔╝ ╚██╔╝ ██║██║ ╚═╝ ██║ +-- ╚═╝ ╚══╝╚══════╝ ╚════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ -- -------------------------------------------------------------------------------- diff --git a/neovim/.config/nvim/lua/autocmds.lua b/neovim/.config/nvim/lua/autocmds.lua index 8ef01b8..9a910a1 100644 --- a/neovim/.config/nvim/lua/autocmds.lua +++ b/neovim/.config/nvim/lua/autocmds.lua @@ -58,6 +58,44 @@ autocmd("TextYankPost", { command = [[silent! lua vim.highlight.on_yank({higroup = "IncSearch", timeout = 100})]] }) +-- Load session file if one exists in the current directory. +augroup("autoSession", {clear = true}) +autocmd("VimEnter", { + group = "autoSession", + callback = + function () + local cwd = func.getcwd() + local session = cwd .. "/Session.vim" + + if func.filereadable(session) ~=0 then + vim.ui.input( + { + prompt = "Detected session file. Restore it? (y/n): " + }, + + function(input) + if input == "y" then + cmd("so ".. session) + vim.g.LoadedFromSession = true + end + end + ) + end + end +}) +autocmd("VimLeave", { + group = "autoSession", + callback = + function () + local cwd = func.getcwd() + local session = cwd .. "/Session.vim" + + if vim.g.LoadedFromSession and func.filewritable(session) ~=0 then + cmd("mksession!") + end + end +}) + -- Track daily thesis progress. augroup("thesisProgress", {clear = true}) local progressScript = "~/Documents/CourseWork/Cambridge/MPhilThesis/paper/progress.sh" diff --git a/neovim/.config/nvim/lua/options.lua b/neovim/.config/nvim/lua/options.lua index 9af066c..2775252 100644 --- a/neovim/.config/nvim/lua/options.lua +++ b/neovim/.config/nvim/lua/options.lua @@ -19,11 +19,10 @@ opt.showmode = false opt.laststatus = 3 opt.spelllang = "en_gb" opt.hidden = true - +opt.mouse = "nv" -- Add OCaml indent tool to runtimepath opt.runtimepath:prepend("~/.opam/cs3110-2023sp/share/ocp-indent/vim") cmd("colorscheme tokyonight") cmd("filetype plugin on") -