Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

btv.diagnostic

btv.diagnostic.get(bufnr, opts)

btv.diagnostic.get([bufnr, [opts]]): diagnostics as plain tables. nil bufnr → every buffer; 0 → the current one. opts.severity filters: one severity (a number or a name like "WARN"), a range { min =, max = } (lower numbers are more severe, so { min = WARN } keeps warnings and errors), or a list of severities. The entries are copied out (callers must not mutate the mirror), each tagged with its bufnr, matching neovim’s shape.

Defined in diagnostic.lua.

btv.diagnostic.goto_next(opts)

btv.diagnostic.goto_next([opts]): move to the next diagnostic in the current buffer, wrapping. opts.severity takes the same shapes as btv.diagnostic.get.

Defined in diagnostic.lua.

btv.diagnostic.goto_prev(opts)

btv.diagnostic.goto_prev([opts]): move to the previous diagnostic, wrapping. opts.severity takes the same shapes as btv.diagnostic.get.

Defined in diagnostic.lua.

btv.diagnostic.toqflist(diagnostics)

btv.diagnostic.toqflist(diagnostics): convert a list of diagnostic tables (the shape btv.diagnostic.get returns) into quickfix/location-list items. Mirrors neovim’s vim.diagnostic.toqflist: 0-based diagnostic positions become 1-based list columns, the message becomes the entry text, and severity maps to the type char. The buffer name is resolved into filename so the entry is jumpable.

Defined in diagnostic.lua.

btv.diagnostic.setqflist(opts)

btv.diagnostic.setqflist([opts]): replace the quickfix list with every buffer’s diagnostics and (unless opts.open == false) open the quickfix window. opts: severity filter, title, open.

Defined in diagnostic.lua.

btv.diagnostic.setloclist(opts)

btv.diagnostic.setloclist([opts]): populate the current window’s location list with the current buffer’s diagnostics (a real, navigable loclist now that one exists) and open it. opts: bufnr (default current), severity, title, open.

Defined in diagnostic.lua.

btv.diagnostic.open_float(opts)

btv.diagnostic.open_float([opts]): open a float listing the cursor line’s diagnostics in full (the multi-line messages with source/code that the inline virtual text truncates). The server reads the cursor at apply time and routes through the float surface (the bottom panel hover uses); a clean line opens nothing.

What bemtvi shows is exactly neovim’s DEFAULT scope = "line", so that value is accepted. Everything else neovim models — scope of "cursor"/"buffer", the severity filter, bufnr/pos, and the presentation options (border, header, source, format) — is rejected loudly rather than dropped: a silently-ignored scope = "buffer" would show one line’s diagnostics while the caller believed it asked for the whole buffer’s.

Defined in diagnostic.lua.

btv.diagnostic.config(opts, _namespace)

btv.diagnostic.config([opts]): merge opts into the stored config and return the merged table when called bare. bemtvi renders three surfaces — the underline spans (underline), the inline end-of-line message (virtual_text), and the gutter sign column (signs) — so those keys drive rendering; update_in_insert gates when an update reaches all three. Any other key is stored without behavior until a surface exists, and warns once naming it.

update_in_insert decides what happens to a diagnostic update that arrives while you are typing. A language server re-diagnoses after every didChange — i.e. after every keystroke — so applied as they land, the squiggles, signs and inline messages churn under the cursor over errors that exist only because the line isn’t finished. bemtvi takes a number of milliseconds here as well as neovim’s two booleans:

-- the default: apply the newest update once typing has been quiet for 3s
btv.diagnostic.config({ update_in_insert = 3000 })

btv.diagnostic.config({ update_in_insert = true })   -- apply every update at once
btv.diagnostic.config({ update_in_insert = false })  -- hold everything until InsertLeave

Nothing is ever dropped: while an update is held the newest one is kept, and leaving insert mode applies it immediately whatever the interval is. Nor does anything drift out of place while you wait — a displayed diagnostic is anchored to the text it flags, so its squiggle, sign, inline message and ]d target follow that text as you edit around it.

INCOMPLETE: virtual_lines, severity_sort, … are recorded and echoed back (with a one-time warning) but have no rendering surface yet (float is honored by btv.diagnostic.open_float, but the config.float defaults that pre-style it are not). _namespace is ignored (one global config). Faithful once those diagnostic surfaces exist.

Defined in diagnostic.lua.

btv.diagnostic.set(namespace, bufnr, diagnostics, _opts)

btv.diagnostic.set(namespace, bufnr, diagnostics[, opts]): replace the diagnostics for (namespace, bufnr). bufnr 0 means the current buffer. The entries are stored as given (each typically { lnum, col, message, severity }); opts (display overrides) is accepted but not yet honored — see the INCOMPLETE note on btv._diagnostics_ns. A plugin drives its own buffer’s diagnostics through this.

Defined in diagnostic.lua.

btv.diagnostic.reset(namespace, bufnr)

btv.diagnostic.reset([namespace, [bufnr]]): clear client-set diagnostics. With no args, every namespace in every buffer; with a namespace, that namespace in every buffer (or just bufnr when given). A plugin calls this when its float closes — it used to crash because the function was missing.

Defined in diagnostic.lua.