diff --git a/config/nvim/lua/fschauen/keymap.lua b/config/nvim/lua/fschauen/keymap.lua index aa11c92..7950c5c 100644 --- a/config/nvim/lua/fschauen/keymap.lua +++ b/config/nvim/lua/fschauen/keymap.lua @@ -67,6 +67,9 @@ nmap('k', 'lpreviouszz', { silent = true }) -- navigate diagnostics nmap('dj', require('fschauen.util').goto_next_diagnostic) nmap('dk', require('fschauen.util').goto_prev_diagnostic) +nmap('dd', require('fschauen.util').toggle_diagnostics) +nmap('do', require('fschauen.util').open_float_diagnostic) +nmap('dh', require('fschauen.util').hide_diagnostics) -- toggle quickfix and loclist nmap('ll', util.toggle_quickfix, { desc = 'Toggle quickfix' } ) diff --git a/config/nvim/lua/fschauen/util.lua b/config/nvim/lua/fschauen/util.lua index 9b3c6ed..93b2e48 100644 --- a/config/nvim/lua/fschauen/util.lua +++ b/config/nvim/lua/fschauen/util.lua @@ -98,6 +98,23 @@ M.goto_prev_diagnostic = function(opts) vim.cmd 'normal zz' end +M.open_float_diagnostic = function(opts) + vim.diagnostic.open_float(vim.tbl_extend('keep', opts or {}, { border = 'rounded' })) +end + +M.toggle_diagnostics = function(bufnr) + bufnr = bufnr or 0 + if vim.diagnostic.is_disabled(bufnr) then + vim.diagnostic.enable(bufnr) + else + vim.diagnostic.disable(bufnr) + end +end + +M.hide_diagnostics = function(bufnr) + vim.diagnostic.hide(nil, bufnr or 0) +end + --- Whether the current window is the last in a given direction. ---@param direction string: one of 'h', 'j', 'k', or 'l' local win_is_last = function(direction)