A small Neovim plugin that jumps between diagnostics and shows the current diagnostic together with available LSP code actions in nui.nvim popups.
Find a file
lw a0906ea991
feat: register user commands and fix related bugs
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.
2026-06-12 11:15:41 +08:00
doc feat: register user commands and fix related bugs 2026-06-12 11:15:41 +08:00
lua/nui-diagnostic feat: register user commands and fix related bugs 2026-06-12 11:15:41 +08:00
LICENSE init 1.0 2026-06-04 16:24:38 +08:00
README.md feat: register user commands and fix related bugs 2026-06-12 11:15:41 +08:00

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.

nui-diagnostic-gif

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_names controls the default severity labels shown in the diagnostic popup.
  • code_actions.max_items limits the number of displayed actions.
  • code_actions.include_disabled = true shows disabled LSP actions; disabled actions are hidden by default.
  • code_actions.kinds filters action kinds and prefixes, for example { "quickfix", "refactor" }.
  • code_actions.sort receives NuiDiagnosticActionTuple entries and can reorder actions before display.
  • code_actions.keys are assigned to visible actions in display order.

Health check

:checkhealth nui-diagnostic

License

MIT