summaryrefslogtreecommitdiff
path: root/lua
diff options
context:
space:
mode:
authorDavid Luevano Alvarado <david@luevano.xyz>2024-02-08 05:05:03 -0600
committerDavid Luevano Alvarado <david@luevano.xyz>2024-02-08 05:05:03 -0600
commit6353af6d08b022924894fd242df8533a8992430b (patch)
tree4062c6a74ba128590525665ba55b30133f86eb67 /lua
parent7f79a6ef4be13a4511dfa8a06c9cedb9dcb3c67a (diff)
feat: add auto-session
Diffstat (limited to 'lua')
-rw-r--r--lua/plugins/auto-session.lua27
-rw-r--r--lua/plugins/lualine.lua3
2 files changed, 29 insertions, 1 deletions
diff --git a/lua/plugins/auto-session.lua b/lua/plugins/auto-session.lua
new file mode 100644
index 0000000..efbfef8
--- /dev/null
+++ b/lua/plugins/auto-session.lua
@@ -0,0 +1,27 @@
+return {
+ 'rmagatti/auto-session',
+ opts = {
+ log_level = 'error',
+ auto_session_enabled = true,
+ auto_session_create_enabled = false,
+ auto_save_enabled = false, -- i only want to save some sessions
+ auto_restore_enabled = true, -- always restore if session exists
+ -- handle closing the neotree window/buffer as it results in errors when loading the session
+ pre_save_cmds = {
+ function()
+ -- dirty way of handling neotree not being loaded yet (lazy load on <leader>nt)
+ local _ = pcall(vim.cmd, 'Neotree close')
+ end,
+ },
+ },
+ config = function(_, opts)
+ local ass = require('auto-session')
+ ass.setup(opts)
+ local sl = require('auto-session.session-lens')
+
+ vim.keymap.set('n', '<leader>asr', ass.RestoreSession, { desc = '[a]uto [s]ession: [r]estore' })
+ vim.keymap.set('n', '<leader>ass', ass.SaveSession, { desc = '[a]uto [s]ession: [s]ave' })
+ vim.keymap.set('n', '<leader>asd', ass.DeleteSession, { desc = '[a]uto [s]ession: [d]elete' })
+ vim.keymap.set('n', '<leader>asl', sl.search_session, { desc = '[a]uto [s]ession: [l]list' })
+ end
+}
diff --git a/lua/plugins/lualine.lua b/lua/plugins/lualine.lua
index c8c6377..3354031 100644
--- a/lua/plugins/lualine.lua
+++ b/lua/plugins/lualine.lua
@@ -2,6 +2,7 @@ return {
'nvim-lualine/lualine.nvim',
dependencies = {
{ 'nvim-tree/nvim-web-devicons', opt = {} },
+ 'rmagatti/auto-session',
},
opts = {
options = {
@@ -12,7 +13,7 @@ return {
},
sections = {
lualine_a = { 'mode' },
- lualine_b = { 'branch', 'diff', 'diagnostics' },
+ lualine_b = { require('auto-session.lib').current_session_name, 'branch', 'diff', 'diagnostics' },
lualine_c = { 'filename' },
lualine_x = { 'encoding', 'fileformat', 'filetype' },
lualine_y = { 'progress' },