Skip to content

Commit

Permalink
chore: QOL improvements
Browse files Browse the repository at this point in the history
+ portability for sessions
+ fix session restore error on loading statusline
  • Loading branch information
kevinm6 committed Feb 17, 2025
1 parent 873e83d commit 819c4f0
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 16 deletions.
4 changes: 2 additions & 2 deletions lazy-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@
"nvim-colorizer.lua": { "branch": "master", "commit": "a065833f35a3a7cc3ef137ac88b5381da2ba302e" },
"nvim-dap": { "branch": "master", "commit": "52302f02fea3a490e55475de52fa4deb8af2eb11" },
"nvim-dap-ui": { "branch": "master", "commit": "bc81f8d3440aede116f821114547a476b082b319" },
"nvim-dbee": { "branch": "master", "commit": "42ddeb6e7bba643e0d8179a6213be9116b1509b3" },
"nvim-dbee": { "branch": "master", "commit": "4cb0e76f99d86352fb42ba31dae596803b865d7f" },
"nvim-jdtls": { "branch": "master", "commit": "2f7bff9b8d2ee1918b36ca55f19547d9d335a268" },
"nvim-lint": { "branch": "master", "commit": "6e9dd545a1af204c4022a8fcd99727ea41ffdcc8" },
"nvim-lspconfig": { "branch": "master", "commit": "7af2c37192deae28d1305ae9e68544f7fb5408e1" },
"nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" },
"nvim-notify": { "branch": "master", "commit": "22f29093eae7785773ee9d543f8750348b1a195c" },
"nvim-treesitter": { "branch": "master", "commit": "38e46a6d7ade5c8718f77b2b9fd98a0f7ab32c1e" },
"nvim-treesitter": { "branch": "master", "commit": "2cade9e3d105732b794bc37e7cb2dc53b1cf99dc" },
"nvim-treesitter-refactor": { "branch": "master", "commit": "d8b74fa87afc6a1e97b18da23e762efb032dc270" },
"nvim-ufo": { "branch": "main", "commit": "a52c92c3bbaa10f0c9b547a50adaa8c7d8b29f94" },
"obsidian.nvim": { "branch": "main", "commit": "ae1f76a75c7ce36866e1d9342a8f6f5b9c2caf9b" },
Expand Down
19 changes: 9 additions & 10 deletions lua/lib/session.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,16 @@ local function delete_session()
vim.ui.select(sessions, {
prompt = "Select session to delete:",
default = nil,
format_item = function(item)
return vim.fn.fnamemodify(item, ":p:t:r")
end,
}, function(choice)
if choice then
vim.fn.jobstart("mv " .. vim.fn.fnameescape(choice) .. " ~/.Trash", {
detach = true,
on_exit = function()
local choice_name = vim.fn.fnamemodify(choice, ":t")
vim.notify(string.format("Session < %s > deleted!", choice_name), vim.log.levels.WARN)
end,
})
local deleted = vim.fn.delete(choice)
if deleted == 0 then
local choice_name = vim.fn.fnamemodify(choice, ":t")
vim.notify(string.format("Session < %s > deleted!", choice_name), vim.log.levels.WARN)
end
end
end)
else
Expand All @@ -57,14 +58,13 @@ local function restore_session()
prompt = " > Select session to restore",
format_item = function(item)
return vim.fn.fnamemodify(item, ":p:t:r")
-- return string.format("%s (%s) ", vim.fn.fnamemodify(item, ":p:t:r"), item)
end,
default = nil,
}, function(choice)
local s_name = vim.fn.fnamemodify(choice, ":p:t:r")
if choice then
vim.cmd.source(choice)
require("core.statusline").session_name = s_name
require("lib.ui.statusline").session_name = s_name
vim.notify(string.format("Session < %s > restored!", choice), vim.log.levels.INFO)
end
end)
Expand All @@ -88,7 +88,6 @@ local function save_session()
end
local new_session_path = string.format("%s/%s.vim", M.dir, input)
vim.cmd.mksession { new_session_path, bang = true }
-- vim.cmd("mksession! " .. mks_path)
vim.notify(string.format("Session < %s > created!", input), vim.log.levels.INFO)
end
end)
Expand Down
4 changes: 2 additions & 2 deletions lua/plugins/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ local M = {
---Winbar
{
dir = vim.fn.stdpath "config" .. "/lua/lib/ui/winbar.lua",
event = { "BufReadPre", "BufNewFile" },
virtual = true,
event = { "BufReadPre", "BufNewFile" },
cmd = "ToggleWinbar",
config = function()
require("lib.ui.winbar").toggle()
Expand Down Expand Up @@ -406,4 +406,4 @@ local M = {
},
}

return M
return M
4 changes: 2 additions & 2 deletions plugin/autocommands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ local filetypes_to_exclude = {
-- require("lib.ui.statusline").toggle()
-- require("lib.ui.winbar").toggle()
-- end,
-- -- once = true
-- once = true,
-- })
-- end

Expand Down Expand Up @@ -282,4 +282,4 @@ autocmd("BufNewFile", {
end
end
end,
})
})

0 comments on commit 819c4f0

Please sign in to comment.