mirror of
https://github.com/iilw/nui-diagnostic.nvim.git
synced 2026-06-21 06:03:03 -06:00
A small Neovim plugin that jumps between diagnostics and shows the current diagnostic together with available LSP code actions in nui.nvim popups.
- Lua 100%
Implement the :NuiDiagnostic{Next,Prev,Open,Close} user commands that the
docs already described but were never registered in setup().
Also fix bugs surfaced while reconciling docs with code:
- init.lua: prev_error keymap was bound to keymaps.prev, so [e never worked
- code_action.lua: max_items was misspelled max_itesm, so the limit was ignored
- health.lua: "$d" format specifier printed literally instead of the count
- popup.lua: state.bufnr was never set, leaking global action keymaps
Update README and help docs: commands section, Lua API call forms,
severity aliases, severity_names default, code_actions option notes, and
remove the nonexistent compatibility-shim claim.
|
||
|---|---|---|
| doc | ||
| lua/nui-diagnostic | ||
| LICENSE | ||
| README.md | ||
nui-diagnostic.nvim
A small Neovim plugin that jumps between diagnostics and shows the current diagnostic together with available LSP code actions in nui.nvim popups.
Features
- Jump to next/previous diagnostics and immediately show context.
- Show diagnostic messages in a popup.
- Show available LSP code actions in a second popup.
- Execute actions with number keys.
- Close popups with
<Esc>or cursor movement. - Optional built-in keymaps.
- User commands for manual use.
- Configurable diagnostic formatting and popup appearance.
Requirements
- Neovim 0.10+
nui.nvim- An LSP client that publishes diagnostics and/or code actions
Installation
lazy.nvim
{
"iilw/nui-diagnostic.nvim",
dependencies = { "MunifTanjim/nui.nvim" },
opts = {}
}
vim.pack
vim.pack.add({
"https://github.com/MunifTanjim/nui.nvim",
"https://github.com/iilw/nui-diagnostic.nvim",
})
require("nui-diagnostic").setup({})
Usage
built-in mappings:
require("nui-diagnostic").setup({
keymaps = {
enabled = true,
},
})
Or manual keymaps:
vim.keymap.set("n", "]d", function()
require("nui-diagnostic").next()
end)
vim.keymap.set("n", "[d", function()
require("nui-diagnostic").prev()
end)
vim.keymap.set("n", "]e", function()
require("nui-diagnostic").next({ severity = "ERROR" })
end)
vim.keymap.set("n", "[e", function()
require("nui-diagnostic").prev({ severity = "ERROR" })
end)
Commands
Commands are registered by require("nui-diagnostic").setup():
| Command | Description |
|---|---|
:NuiDiagnosticNext [severity] |
Jump to the next diagnostic and open popups. |
:NuiDiagnosticPrev [severity] |
Jump to the previous diagnostic and open popups. |
:NuiDiagnosticOpen [severity] |
Open popups for diagnostics at the current cursor line. |
:NuiDiagnosticClose |
Close active popups. |
severity is optional. String aliases are case-insensitive and include error, err, warn, warning, info, and hint.
Lua API
local diagnostic = require("nui-diagnostic")
diagnostic.next()
diagnostic.prev()
diagnostic.open()
diagnostic.close()
-- Filter by severity.
diagnostic.next({ severity = "ERROR" })
diagnostic.prev({ severity = "warn" })
diagnostic.open({ severity = vim.diagnostic.severity.INFO })
-- Positional form is also supported.
diagnostic.next(2, "error")
diagnostic.prev(1, "warn")
Configuration
Default options:
require("nui-diagnostic").setup({
popup = {
width = 50,
max_width = 80,
max_height = 12,
border_style = "rounded",
position = { row = 1, col = 0 },
win_options = {
wrap = false,
winblend = 0,
},
},
diagnostics = {
enabled = true,
max_items = nil,
format = nil,
severity_names = {
[vim.diagnostic.severity.ERROR] = "ERROR",
[vim.diagnostic.severity.WARN] = "WARN",
[vim.diagnostic.severity.INFO] = "INFO",
[vim.diagnostic.severity.HINT] = "HINT",
},
},
code_actions = {
enabled = true,
max_items = 9,
include_disabled = false,
kinds = nil,
sort = nil,
keys = { "1", "2", "3", "4", "5", "6", "7", "8", "9" },
},
close = {
key = "<Esc>",
events = { "BufLeave", "CursorMoved", "InsertEnter" },
},
keymaps = {
enabled = true,
next = "]d",
prev = "[d",
next_error = "]e",
prev_error = "[e",
},
notify = true,
})
Notes:
diagnostics.format(diagnostic)can override the displayed diagnostic line.diagnostics.severity_namescontrols the default severity labels shown in the diagnostic popup.code_actions.max_itemslimits the number of displayed actions.code_actions.include_disabled = trueshows disabled LSP actions; disabled actions are hidden by default.code_actions.kindsfilters action kinds and prefixes, for example{ "quickfix", "refactor" }.code_actions.sortreceivesNuiDiagnosticActionTupleentries and can reorder actions before display.code_actions.keysare assigned to visible actions in display order.
Health check
:checkhealth nui-diagnostic
License
MIT