fix: fixing a lot of issues

This commit is contained in:
2026-02-04 21:36:54 -05:00
parent 1d4bf34902
commit 6e904f8f87
98 changed files with 872 additions and 528 deletions

View File

@@ -27,6 +27,8 @@ M.menu_items = {
{ key = "g", icon = "", desc = "Find in Files", action = ":Telescope live_grep" },
{ key = "s", icon = "", desc = "Restore Session", action = ":lua require('persistence').load()" },
{ key = "e", icon = "", desc = "Explorer", action = ":NvimTreeToggle" },
{ key = "l", icon = "󰒲", desc = "Lazy", action = ":Lazy" },
{ key = "m", icon = "", desc = "Mason", action = ":Mason" },
{ key = "c", icon = "", desc = "Settings", action = ":e $MYVIMRC" },
{ key = "q", icon = "", desc = "Quit", action = ":qa" },
}

View File

@@ -35,24 +35,29 @@ keymap.set("n", "<C-e>", "10<C-e>", { noremap = true, silent = true })
keymap.set("n", "<C-y>", "10<C-y>", { noremap = true, silent = true })
-- Buffer management with safe close (confirms if unsaved changes)
-- Closes only the current buffer, switches to another buffer instead of quitting
-- Uses snacks.bufdelete for smart buffer deletion, shows dashboard on last buffer
local function close_buffer(force)
local current_buf = vim.api.nvim_get_current_buf()
local buffers = vim.tbl_filter(function(buf)
return vim.api.nvim_buf_is_valid(buf) and vim.bo[buf].buflisted
end, vim.api.nvim_list_bufs())
if #buffers > 1 then
-- Switch to previous buffer before closing
vim.cmd("bprevious")
if force then
vim.cmd("bdelete! " .. current_buf)
else
vim.cmd("bdelete " .. current_buf)
end
local ok, snacks = pcall(require, "snacks")
if ok and snacks.bufdelete then
-- snacks.bufdelete handles everything smartly
snacks.bufdelete({ force = force })
else
-- Last buffer: quit Neovim
vim.cmd(force and "q!" or "q")
-- Fallback to manual handling
local current_buf = vim.api.nvim_get_current_buf()
local buffers = vim.tbl_filter(function(buf)
return vim.api.nvim_buf_is_valid(buf) and vim.bo[buf].buflisted
end, vim.api.nvim_list_bufs())
if #buffers > 1 then
vim.cmd("bprevious")
vim.cmd((force and "bdelete! " or "bdelete ") .. current_buf)
else
-- Last buffer: show dashboard instead of quitting
vim.cmd("enew")
if ok and snacks.dashboard then
snacks.dashboard()
end
end
end
end

View File

@@ -274,55 +274,6 @@ vim.api.nvim_create_autocmd("FileType", {
end,
})
-- =============================================================================
-- RETURN TO DASHBOARD ON LAST BUFFER CLOSE
-- =============================================================================
-- When closing the last buffer, return to dashboard instead of quitting
vim.api.nvim_create_autocmd("BufDelete", {
callback = function(args)
-- Count listed buffers excluding the one being deleted
local bufs = vim.tbl_filter(function(b)
return vim.api.nvim_buf_is_valid(b)
and vim.bo[b].buflisted
and vim.api.nvim_buf_get_name(b) ~= ""
and b ~= args.buf -- Exclude the buffer being deleted
end, vim.api.nvim_list_bufs())
-- If no listed buffers remain, open dashboard
if #bufs == 0 then
vim.schedule(function()
-- Skip if any special windows are open
local dominated_filetypes = {
"NvimTree", "neo-tree", "Trouble", "qf", "help",
"dap-repl", "dapui_watches", "dapui_stacks",
"dapui_breakpoints", "dapui_scopes", "dapui_console",
"snacks_dashboard", "lazygit", "terminal",
}
for _, win in ipairs(vim.api.nvim_list_wins()) do
local buf = vim.api.nvim_win_get_buf(win)
local ft = vim.bo[buf].filetype
if vim.tbl_contains(dominated_filetypes, ft) then
return
end
end
-- Don't open if dashboard is already visible
local current_ft = vim.bo.filetype
if current_ft == "snacks_dashboard" then
return
end
local ok, snacks = pcall(require, "snacks")
if ok and snacks.dashboard then
snacks.dashboard()
end
end)
end
end,
})
-- =============================================================================
-- MODERN UI: GLOBAL ROUNDED BORDERS
-- =============================================================================