diff --git a/lua/dot013/plugins/ide.lua b/lua/dot013/plugins/ide.lua index 7c95beb..60746e4 100644 --- a/lua/dot013/plugins/ide.lua +++ b/lua/dot013/plugins/ide.lua @@ -16,6 +16,25 @@ return { end, }, + -- Session restore, enabled automatically in git repos + { + "auto-session", + lazy = not require("dot013.utils").is_in_cwd(".git"), + cmd = { + "SessionSave", + "SessionRestore", + "SessionDelete", + "SessionDisableAutoSave", + "SessionToggleSave", + "SessionPurgeOrphaned", + "SessionSearch", + "Auutosession", + }, + after = function() + require("auto-session").setup() + end, + }, + -- Completion { "blink-cmp", @@ -89,9 +108,6 @@ return { ft = { "sh" }, }, - -- Session restore { - "vim-obsession", - cmd = "Obsess", }, } diff --git a/lua/dot013/utils.lua b/lua/dot013/utils.lua new file mode 100644 index 0000000..1cdaa76 --- /dev/null +++ b/lua/dot013/utils.lua @@ -0,0 +1,23 @@ +local M = {} + +M.is_in_cwd = function(name) + local cwd = vim.fn.getcwd() + local cwdContent = vim.split(vim.fn.glob(cwd .. "/*"), "\n", { trimempty = true }) + local hiddenCwdContent = vim.split(vim.fn.glob(cwd .. "/.*"), "\n", { trimempty = true }) + + for _, f in pairs(hiddenCwdContent) do + table.insert(cwdContent, f) + end + + local fullName = cwd .. "/" .. name + + for _, f in pairs(cwdContent) do + if f == fullName then + return true + end + end + + return false +end + +return M