mirror of
https://github.com/neovim/neovim
synced 2025-07-16 01:01:49 +00:00
feat(defaults): "Show Diagnostics" in mouse popupmenu #32122
Problem: No obvious way to see diagnostics without configuring it first. Solution: Add `Show Diagnostics`, `Show All Diagnostics` and `Configure Diagnostics` buttons to the context menu.
This commit is contained in:
@ -221,6 +221,8 @@ DEFAULTS
|
||||
on a URL.
|
||||
• Mouse |popup-menu| includes a "Go to definition" item when LSP is active
|
||||
in the buffer.
|
||||
• Mouse |popup-menu| includes "Show Diagnostics", "Show All Diagnostics" and
|
||||
"Configure Diagnostics" items when there are diagnostics in the buffer.
|
||||
• |]d-default| and |[d-default| accept a count.
|
||||
• |[D-default| and |]D-default| jump to the first and last diagnostic in the
|
||||
current buffer, respectively.
|
||||
|
@ -383,9 +383,12 @@ end
|
||||
do
|
||||
--- Right click popup menu
|
||||
vim.cmd([[
|
||||
anoremenu PopUp.Go\ to\ definition <Cmd>lua vim.lsp.buf.definition()<CR>
|
||||
amenu PopUp.Open\ in\ web\ browser gx
|
||||
anoremenu PopUp.Inspect <Cmd>Inspect<CR>
|
||||
anoremenu PopUp.Go\ to\ definition <Cmd>lua vim.lsp.buf.definition()<CR>
|
||||
anoremenu PopUp.Show\ Diagnostics <Cmd>lua vim.diagnostic.open_float()<CR>
|
||||
anoremenu PopUp.Show\ All\ Diagnostics <Cmd>lua vim.diagnostic.setqflist()<CR>
|
||||
anoremenu PopUp.Configure\ Diagnostics <Cmd>help vim.diagnostic.config()<CR>
|
||||
anoremenu PopUp.-1- <Nop>
|
||||
vnoremenu PopUp.Cut "+x
|
||||
vnoremenu PopUp.Copy "+y
|
||||
@ -403,6 +406,9 @@ do
|
||||
vim.cmd([[
|
||||
amenu disable PopUp.Go\ to\ definition
|
||||
amenu disable PopUp.Open\ in\ web\ browser
|
||||
amenu disable PopUp.Show\ Diagnostics
|
||||
amenu disable PopUp.Show\ All\ Diagnostics
|
||||
amenu disable PopUp.Configure\ Diagnostics
|
||||
]])
|
||||
|
||||
if ctx == 'url' then
|
||||
@ -410,6 +416,20 @@ do
|
||||
elseif ctx == 'lsp' then
|
||||
vim.cmd([[anoremenu enable PopUp.Go\ to\ definition]])
|
||||
end
|
||||
|
||||
local lnum = vim.fn.getcurpos()[2] - 1 ---@type integer
|
||||
local diagnostic = false
|
||||
if next(vim.diagnostic.get(0, { lnum = lnum })) ~= nil then
|
||||
diagnostic = true
|
||||
vim.cmd([[anoremenu enable PopUp.Show\ Diagnostics]])
|
||||
end
|
||||
|
||||
if diagnostic or next(vim.diagnostic.count(0)) ~= nil then
|
||||
vim.cmd([[
|
||||
anoremenu enable PopUp.Show\ All\ Diagnostics
|
||||
anoremenu enable PopUp.Configure\ Diagnostics
|
||||
]])
|
||||
end
|
||||
end
|
||||
|
||||
local nvim_popupmenu_augroup = vim.api.nvim_create_augroup('nvim.popupmenu', {})
|
||||
|
Reference in New Issue
Block a user