Closed MaciekFlis closed 1 year ago
Check out the vim.diagnostic
API (:h diagnotic
in neovim).
For floating windows, you want [vim.diagnostic.open_float()
](https://neovim.io/doc/user/diagnostic.html#vim.diagnostic.open_float()), and possibly goto_prev
and goto_next
to navigate them.
Personally, I have the following keymaps:
local diagnostic= vim.diagnostic
local keymap = vim.keymap
local severity = diagnostic.severity
local opts = { noremap = true, silent = true }
keymap.set('n', '<space>e', function()
local _, winid = diagnostic.open_float(nil, { scope = 'line' })
vim.api.nvim_win_set_config(winid or 0, { focusable = true })
end, opts)
keymap.set('n', '[d', diagnostic.goto_prev, opts)
keymap.set('n', ']d', diagnostic.goto_next, opts)
keymap.set('n', '[e', function()
diagnostic.goto_prev {
severity = severity.ERROR,
}
end, opts)
keymap.set('n', ']e', function()
diagnostic.goto_next {
severity = severity.ERROR,
}
end, opts)
keymap.set('n', '[w', function()
diagnostic.goto_prev {
severity = severity.WARN,
}
end, opts)
keymap.set('n', ']w', function()
diagnostic.goto_next {
severity = severity.WARN,
}
end, opts)
keymap.set('n', '[h', function()
diagnostic.goto_prev {
severity = severity.HINT,
}
end, opts)
keymap.set('n', ']h', function()
diagnostic.goto_next {
severity = severity.HINT,
}
end, opts)
You may also want to check out this plugin.
this is exactly what I needed, thank you! do you know how to hide the current inline diagnostic?
Thanks for the donation ☺️
Yes, you can disable them with
vim.diagnostic.config({
virtual_text = false,
})
@all-contributors please add @MaciekFlis for financial
@mrcjkb
I've put up a pull request to add @MaciekFlis! :tada:
works like a charm, thank you
Question
I don't want my warnings or errors to show inline, I'm never able to read full text.
how can I make it display in a hover window, like in this gif in readme: