local map = vim.keymap.set map("n", "s", ":w", {}) map("n", "q", function() local buffers = vim.fn.getbufinfo({ buflisted = 1 }) if #buffers <= 1 then -- Check if explorer is already open local explorer_win = nil for _, win in ipairs(vim.api.nvim_list_wins()) do local buf = vim.api.nvim_win_get_buf(win) local ft = vim.api.nvim_get_option_value("filetype", { buf = buf }) if ft == "snacks_picker_list" then explorer_win = win break end end vim.cmd("bdelete") if explorer_win then -- Explorer is already open, just focus it vim.api.nvim_set_current_win(explorer_win) else -- Explorer not open, open it Snacks.explorer() end else vim.cmd("bnext") vim.cmd("bdelete #") end end, { desc = "Smart buffer delete" }) map("n", "qq", ":q'", {}) map("n", "qqq", ":qa!", {}) map("n", "s", ":w", {}) map("n", "mm", "gcc", { desc = "Toggle comment", remap = true }) map("v", "mm", "gc", { desc = "Toggle comment", remap = true }) -- Diagnostics map("n", "d", function() Snacks.picker.diagnostics() end, { desc = "Show Diagnostics" })