diff options
-rw-r--r-- | runtime/doc/news.txt | 2 | ||||
-rw-r--r-- | runtime/lua/vim/_defaults.lua | 22 |
2 files changed, 23 insertions, 1 deletions
diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt index bfa98dce05..1f1ad84a02 100644 --- a/runtime/doc/news.txt +++ b/runtime/doc/news.txt @@ -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. diff --git a/runtime/lua/vim/_defaults.lua b/runtime/lua/vim/_defaults.lua index 69204e3fe6..b1e5687d74 100644 --- a/runtime/lua/vim/_defaults.lua +++ b/runtime/lua/vim/_defaults.lua @@ -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', {}) |