refactor(ide): use auto-session instead of Obsession.vim

This commit is contained in:
Guz
2024-12-07 12:01:12 -03:00
parent 3b841c48ca
commit 9e0881dfc8
2 changed files with 42 additions and 3 deletions

View File

@@ -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",
},
}

23
lua/dot013/utils.lua Normal file
View File

@@ -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