From a06e2d805c458e1e151b7a62ef2b0e7eb147d563 Mon Sep 17 00:00:00 2001 From: gered Date: Mon, 7 Oct 2024 20:41:51 -0400 Subject: [PATCH] add quit/close to most menus. more ignore filetype menu filtering --- nvim/lua/plugins/menu.lua | 39 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/nvim/lua/plugins/menu.lua b/nvim/lua/plugins/menu.lua index 91391f8..d1c2625 100644 --- a/nvim/lua/plugins/menu.lua +++ b/nvim/lua/plugins/menu.lua @@ -459,6 +459,32 @@ function get_git_menu() } end +local quit_only_ft = { + 'help', + 'Outline', + 'trouble', + 'toggleterm', + 'man', +} + +function add_close_quit_menuitem(tbl) + if table.getn(tbl) > 0 then + table.insert(tbl, { name = 'separator' }) + end + if not helper.contains(quit_only_ft, vim.bo.ft) then + table.insert(tbl, { + name = ' Close Buffer', + cmd = 'BufferClose', + rtxt = 'bd', + }) + end + table.insert(tbl, { + name = ' Quit Window', + cmd = 'q', + rtxt = 'q', + }) +end + return { { 'nvchad/volt', @@ -466,9 +492,12 @@ return { 'nvchad/menu', config = function() local ignore_ft = { - 'help', - 'Outline', - 'trouble', + 'dapui_scopes', + 'dapui_breakpoints', + 'dapui_stacks', + 'dapui_watches', + 'dap-repl', + 'dapui_console', } vim.keymap.set('n', '', function() if not helper.contains(ignore_ft, vim.bo.ft) then @@ -476,8 +505,12 @@ return { local menu if vim.bo.ft == 'NvimTree' then menu = get_nvim_tree_menu() + elseif helper.contains(quit_only_ft, vim.bo.ft) then + menu = {} + add_close_quit_menuitem(menu) else menu = get_default_menu() + add_close_quit_menuitem(menu) end require('menu').open(menu, { mouse = true }) end