aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/_defaults.lua
diff options
context:
space:
mode:
authorGregory Anders <8965202+gpanders@users.noreply.github.com>2024-04-26 13:16:12 -0500
committerGitHub <noreply@github.com>2024-04-26 13:16:12 -0500
commit73034611c25d16df5e87c8afb2d339a03a91bd0d (patch)
tree9280e1fb5476a61ebf90073f24ec244ef2204f01 /runtime/lua/vim/_defaults.lua
parent3a7c30dc93b9b903ff8591c43689c3bdcb4761de (diff)
downloadrneovim-73034611c25d16df5e87c8afb2d339a03a91bd0d.tar.gz
rneovim-73034611c25d16df5e87c8afb2d339a03a91bd0d.tar.bz2
rneovim-73034611c25d16df5e87c8afb2d339a03a91bd0d.zip
feat(diagnostic): add default mappings for diagnostics (#16230)
Diffstat (limited to 'runtime/lua/vim/_defaults.lua')
-rw-r--r--runtime/lua/vim/_defaults.lua33
1 files changed, 32 insertions, 1 deletions
diff --git a/runtime/lua/vim/_defaults.lua b/runtime/lua/vim/_defaults.lua
index b1cd4f6ec6..98dfbf3225 100644
--- a/runtime/lua/vim/_defaults.lua
+++ b/runtime/lua/vim/_defaults.lua
@@ -127,7 +127,9 @@ do
end, { desc = gx_desc })
end
- --- Default maps for built-in commenting
+ --- Default maps for built-in commenting.
+ ---
+ --- See |gc-default| and |gcc-default|.
do
local operator_rhs = function()
return require('vim._comment').operator()
@@ -169,6 +171,35 @@ do
vim.lsp.buf.signature_help()
end, { desc = 'vim.lsp.buf.signature_help()' })
end
+
+ --- Map [d and ]d to move to the previous/next diagnostic. Map <C-W>d to open a floating window
+ --- for the diagnostic under the cursor.
+ ---
+ --- See |[d-default|, |]d-default|, and |CTRL-W_d-default|.
+ do
+ vim.keymap.set('n', ']d', function()
+ vim.diagnostic.goto_next({ float = false })
+ end, {
+ desc = 'Jump to the next diagnostic with the highest severity',
+ })
+
+ vim.keymap.set('n', '[d', function()
+ vim.diagnostic.goto_prev({ float = false })
+ end, {
+ desc = 'Jump to the previous diagnostic with the highest severity',
+ })
+
+ vim.keymap.set('n', '<C-W>d', function()
+ vim.diagnostic.open_float({ border = 'rounded' })
+ end, {
+ desc = 'Open a floating window showing diagnostics under the cursor',
+ })
+
+ vim.keymap.set('n', '<C-W><C-D>', '<C-W>d', {
+ remap = true,
+ desc = 'Open a floating window showing diagnostics under the cursor',
+ })
+ end
end
--- Default menus