add quit/close to most menus. more ignore filetype menu filtering

This commit is contained in:
Gered 2024-10-07 20:41:51 -04:00
parent c4547c7dec
commit a06e2d805c

View file

@ -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 = '<leader>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', '<RightMouse>', 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