speedie-nvim/lua/session_manager.lua

30 lines
1,013 B
Lua
Raw Normal View History

2024-01-19 23:06:16 +01:00
--[[
speedie's neovim configuration
-- https://git.speedie.site/speedie/speedie-nvim --
]]--
2024-01-30 16:16:38 +01:00
-- Hardcoded because I doubt anyone cares to change this.
SessionFile = vim.fn.stdpath('data') .. '/.session_file.nvim'
2024-01-19 23:06:16 +01:00
if LoadPreviousSessionOnLoad and SessionFile ~= '' then
vim.api.nvim_create_autocmd('VimEnter', { -- Restore session on load
pattern = { '*' },
callback = function()
local _sessionFile = vim.fn.expand(SessionFile)
if vim.fn.argc() == 0 then
if vim.fn.filereadable(_sessionFile) == 1 then
2024-02-29 18:27:18 +01:00
vim.cmd('silent source ' .. _sessionFile)
vim.cmd("silent filetype detect")
2024-01-19 23:06:16 +01:00
end
end
end,
})
vim.api.nvim_create_autocmd('VimLeave', { -- Save session on exit
pattern = { '*' },
callback = function()
local _sessionFile = vim.fn.expand(SessionFile)
vim.cmd('mksession! ' .. _sessionFile)
end,
})
end