diff --git a/config/nvim/lua/user/keymap.lua b/config/nvim/lua/user/keymap.lua index 97b566d..63574a9 100644 --- a/config/nvim/lua/user/keymap.lua +++ b/config/nvim/lua/user/keymap.lua @@ -63,6 +63,10 @@ nmap('', 'cpreviouszz', { silent = true }) nmap('', 'lnextzz', { silent = true }) nmap('', 'lpreviouszz', { silent = true }) +-- navigate diagnostics +nmap('j', require('user.util').goto_next_diagnostic) +nmap('k', require('user.util').goto_prev_diagnostic) + -- quickly open lazy.nvim plugin manager nmap('L', 'Lazy') diff --git a/config/nvim/lua/user/util.lua b/config/nvim/lua/user/util.lua index ecf5b92..f5c79eb 100644 --- a/config/nvim/lua/user/util.lua +++ b/config/nvim/lua/user/util.lua @@ -56,6 +56,23 @@ M.get_selected_text = function() end) end +local diag_opts = { + wrap = false, -- don't wrap around the begin/end of file + float = { + border = 'rounded' -- enable border for the floating window + }, +} + +-- Move to the next diagnostic. +M.goto_next_diagnostic = function(opts) + vim.diagnostic.goto_next(vim.tbl_extend('keep', opts or {}, diag_opts)) +end + +-- Move to the previous diagnostic. +M.goto_prev_diagnostic = function(opts) + vim.diagnostic.goto_prev(vim.tbl_extend('keep', opts or {}, diag_opts)) +end + M.use_local = function() end