aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/diagnostic.lua
Commit message (Collapse)AuthorAge
* feat(diagnostic): add source option to virtual_lines handler (#42371)Aradhya Jain5 days
| | | | | | | | | | | | vim.diagnostic.Opts.VirtualText has a `source` option to prefix diagnostic messages with their source (`'if_many'` or always), but the newer virtual_lines handler never got the same option, even though the shared helpers it needs (diagnostic_shared.prefix_source/count_sources) are already render-target-agnostic and used by virtual_text as-is. Add the same `source` field to vim.diagnostic.Opts.VirtualLines and apply it in the virtual_lines handler right after message formatting, mirroring virtual_text's own ordering (format first, then prefix the source onto the already-formatted message).
* Merge #41944 from epithet/stl-hl-scopesJustin M. Keyes2026-09-30
|\
| * fix(statusline): combine diagnostic highlights, use highlight scopesSébastien Hoffmann2026-09-26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: when the highlighting surrounding the diagnostics section is not StatusLine[NC], the in-section highlights are not combined and not correctly reset afterwards. The spaces between the diagnostic items have the highlight of the item to the left, which looks bad when the Diagnostic* highlight groups are customised with background colour or underlines. Solution: use %$ to combine, and %#(...%#) to reset. ref #36685 ref #35806
* | fix(lua): enable unnecessary-assert diagnosticLewis Russell2026-09-28
|/ | | | AI-assisted
* fix(lua): enable assignment type checking in runtime codeLewis Russell2026-09-25
| | | | | | | | | | | Enable EmmyLua's assign-type-mismatch diagnostic after correcting the runtime annotations and assignments it flags. Correct option, tuple, and return types, and use separate locals when a value changes representation. Add guards and narrow casts where needed so the runtime passes the stricter check. Regenerate the affected docs. AI-assisted
* fix(lua): enable nil-safety diagnostics in runtime codeLewis Russell2026-09-25
| | | | | | | | | | | | Enable EmmyLua's need-check-nil diagnostic and resolve nullable values through more precise types, explicit invariants, and guards for missing runtime state. Keep analyzer-specific workarounds local and update the affected API documentation. Exclude the bundled re.lua from analysis so its nil-check warnings do not fail CI. AI-assisted
* fix(diagnostic): default absent quickfix coordinatesLewis Russell2026-09-25
| | | | | | | | | Quickfix entries can omit their start and end positions. Default absent start coordinates to the first position and absent end coordinates to the start, avoiding arithmetic and comparisons on nil. Cover both cases in the conversion tests. AI-assisted
* build: enable more EmmyLua checksLewis Russell2026-09-08
| | | | | | | | | | | | | | | | - call-non-callable - missing-fields - redefined-label - redefined-local - undefined-field - unreachable-code Promote redefined-local and unreachable-code to warnings. Fix DOS line-ending handling for multiline semantic tokens, and support intersection types in the help parser. AI-assisted
* docs(api): buffer columns are byte indices #41137Barrett Ruth2026-08-04
|
* refactor(api): omit optional paramJustin M. Keyes2026-07-13
|
* feat(diagnostic): debounce current-line render #39542Oleh Volynets2026-06-15
| | | | | | | | | | | Problem: vim.diagnostic.Opts.VirtualLines.current_line and vim.diagnostic.Opts.VirtualText.current_line cause redraw on every CursorMoved event that makes the text jump uncomfortably with rapid cursor movement. Solution: `current_line` state is applied only on CursorHold, while still being cleared on CursorMoved making it so that until the cursor has stopped on a line, its diagnostic looks like cursor is not on the line preventing flicker.
* feat(diagnostic): add virt_lines_overflow option for virtual_lines #40178John Reid2026-06-13
| | | | | | | Problem: Diagnostic virtual lines are hardcoded with "scroll" for virt_lines_overflow option. Solution: Add a `overflow` option to `virtual_lines` config to support "wrap", "scroll", "trunc", and "auto".
* docs: misc, options, pos/rangeJustin M. Keyes2026-05-30
|
* fix(lsp): unwanted redraw for buffer not in window #40002luukvbaal2026-05-27
| | | | | Problem: Redrawing when a loaded buffer is not shown in any window on the current tabpage. Solution: Check that buffer is shown in a (normal) window before redrawing.
* refactor: introduce nvim_on internally #39883Justin M. Keyes2026-05-20
| | | | | | | | | Problem: `nvim_create_autocmd` is too verbose and its `callback` requires extra "nesting". Solution: Introduce `nvim_on`. Start using it internally. Then we can get a feel for how it should look before making it public.
* fix(diagnostic): handle `signs = false` in `status()` (#39703)Maria Solano2026-05-09
|
* docs: misc, rename "tabpage"Justin M. Keyes2026-05-07
| | | | | | Co-authored-by: michael-grunder <michael.grunder@gmail.com> Co-authored-by: Olivia Kinnear <git@superatomic.dev> Co-authored-by: Felipe Matarazzo <felipemps@protonmail.com>
* feat(lua)!: vim.isnil, vim.nonnil, deprecate vim.F #39495Olivia Kinnear2026-05-06
|
* feat(diagnostic)!: deprecate `format` as a table #39603Yi Ming2026-05-06
|
* fix(diagnostic): status() respects config.signs #39525Yi Ming2026-05-05
| | | | | | | | | Problem: `diagnostic.status` only follows the `config.status.format` setting to determine how to display diagnostic signs. However, `signs` can actually also be configured via `config.signs.text`. Solution: If the user has set symbols via `config.status.format`, let that determine the content of `signs`; otherwise, use `config.signs.text` for display. TODO: drop support `type(config.status.format) == 'table'`; users should just configure `config.signs.text` directly.
* build(lint): allow "bufnr" as positional param #39515Justin M. Keyes2026-04-30
| | | | | Allow `bufnr` as a positional param name because it is very common. However as a field name, or part of a function name, it is usually a mistake.
* docs: misc #39207Justin M. Keyes2026-04-20
|
* refactor: update usages of deprecated "buffer" param #39089Justin M. Keyes2026-04-15
|
* refactor(diagnostic): split diagnostic moduleLewis Russell2026-04-15
| | | | | | | | | | | | | | | Extract the diagnostic implementation from runtime/lua/vim/diagnostic.lua into focused internal modules covering config, display, float rendering, jump/list helpers, namespace and storage management, severity/shared utilities, and statusline support. Move the builtin handlers into runtime/lua/vim/diagnostic/handlers/ and keep runtime/lua/vim/diagnostic.lua as the public facade that lazily dispatches to the split modules. This preserves the external vim.diagnostic API while making the implementation easier to navigate and reason about. AI-assisted: Codex
* feat(api): rename buffer to buf #35330Jordan2026-04-08
| | | | | | | | | | | | Problem: `:help dev-name-common` states that "buf" should be used instead of "buffer" but there are cases where buffer is mentioned in the lua API. Solution: - Rename occurrences of "buffer" to "buf" for consistency with the documentation. - Support (but deprecate) "buffer" for backwards compatibility. Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
* fix(diagnostic): virtual_lines should anchor at end_lnum, not lnum #38701glepnir2026-04-06
| | | | | Problem: Multi-line diagnostics always render virtual lines below lnum. Solution: Use end_lnum when placing the virt_lines extmark.
* feat(lua): replace `buffer` with `buf` in vim.keymap.set/del #38360skewb1k2026-03-21
| | | | | | The `buffer` option remains functional but is now undocumented. Providing both will raise an error. Since providing `buf` was disallowed before, there is no code that will break due to using `buffer` alongside `buf`.
* fix(diagnostic): open_float() handles config.float function #31577glepnir2026-03-16
| | | | | | | | Problem: The `float` field of vim.diagnostic.config can be a function, but diagnostic.open_float() does not handle it correctly. Solution: Add handling for it in open_float().
* refactor: rename _ensure_integer => _assert_integerJustin M. Keyes2026-03-13
|
* feat(diagnostic): custom status format function #36696Oleh Volynets2026-03-13
| | | | | | | Problem: Statusline component of diagnostics allows only the default format "sign:count". Solution: Extend vim.diagnostic.Opts.Status to allow a custom signs or formatting function that provides the status presentation.
* refactor: integer functions, optimize asserts #34112Lewis Russell2026-03-12
| | | | | | | | | | | | refactor(lua): add integer coercion helpers Add vim._tointeger() and vim._ensure_integer(), including optional base support, and switch integer-only tonumber()/assert call sites in the Lua runtime to use them. This also cleans up related integer parsing in LSP, health, loader, URI, tohtml, and Treesitter code. supported by AI
* fix(diagnostic): handle stale diagnostic extmark ids #38060Mathias Fußenegger2026-02-25
| | | | | | | | | | | | | | | Problem: If a server is slow with catching up, there can be stale diagnostics for deleted lines. Then if a user uses `jump` it can error like: E5108: Lua: ...runtime/lua/vim/diagnostic.lua:670: attempt to index a nil value stack traceback: ...runtime/lua/vim/diagnostic.lua:670: in function 'get_logical_pos' ...runtime/lua/vim/diagnostic.lua:687: in function 'diagnostic_lines' ...runtime/lua/vim/diagnostic.lua:1122: in function 'next_diagnostic' ...runtime/lua/vim/diagnostic.lua:1665: in function 'jump' Solution: Fallback to diagnostic location. That's better than the failure.
* feat(diagnostic): fromqflist({merge_lines}) #37416Dmytro Pletenskyi2026-02-14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: `vim.diagnostic.fromqflist` ignores lines that are `item.valid == 0` (see `getqflist`). Many qflists have messages that span multiple lines, which look like this: collection/src/Modelling/CdOd/Central.hs|496 col 80| error: [GHC-83865] || • Couldn't match expected type: InstanceWithForm || (FilePath || -> SelectValidCdInstWithForm ... calling `vim.diagnostic.fromqflist(vim.fn.getqflist)` gets a diagnostic message like this: error: [GHC-83865] only the first line is kept, but often, the remaing lines are useful as well. Solution: Introduce `merge_lines` option, which "squashes" lines from invalid qflist items into the error message of the previous valid item, so that we get this diagnostic message instead: error: [GHC-83865] • Couldn't match expected type: InstanceWithForm (FilePath -> SelectValidCdInstWithForm
* fix(types): add missing @return annotationsJosh Cooper2026-01-28
|
* fix(diagnostics): assert adjusted diagnostic position #37210Sergei Slipchenko2026-01-26
| | | | | | | | | Problem: During diagnostic position adjustment we may go out of bounds when trying to get line's length. But it's not clear what kind of input triggers that. Solution: Assert and print relevant input values.
* fix(diagnostic): display 1-based related information line/col numbers (#37093)Robert Muir2026-01-04
| | | | | | | | | Problem LSP Related Information line and column numbers are 0-based. Displaying them this way can confuse the user, since vim line/col numbers are typically displayed 1-based. Solution Display the line and column numbers as 1-based.
* fix(diagnostic): check for extmark in get_logical_pos #37127Kira Kawai2026-01-02
| | | | | Problem: The function get_logical_pos did not account for the possibility that a diagnostic might not have an associated extmark, leading to potential errors or incorrect behavior. Solution: Add a check for diagnostic._extmark_id and return the logical positions directly if it does not exist.
* fix(diagnostic): unstable sorting by severity #37154glepnir2025-12-30
| | | | | Problem: random order for same-severity diagnostics, severity_sort reversed. Solution: add stable comparison with _extmark_id tiebreaker.
* feat(diagnostic): config.status #36693Maria Solano2025-11-25
| | | | | | | | Problem: `diagnostic.status()` is configured via `config.signs`, but users may want diagnostics only in statusline, not in the gutter (signs). Solution: Add `config.status`.
* feat(diagnostic): highlights in diagnostic.status() #36685Riley Bruins2025-11-25
| | | | Applies the appropriate `DiagnosticSign*` highlight to each group, resetting the highlights at the end of the expression.
* docs(diagnostic): diagnostic.Opts.Float extend open_floating_preview.Opts #30058glepnir2025-11-18
| | | | | | | | Problem: the opts table also is param of util.open_floating_preview, vim.diagnostic.Opts.Float missing some fields of open_floating_preview. Solution: diagnostic.Opts.Float extend util.open_floating_preview.Opts Fix #29267
* feat(diagnostics): stack DiagnosticUnnecessary,DiagnosticDeprecated ↵Grzegorz Rozdzialik2025-11-17
| | | | | | | | | | | | | | | | | highlights #36590 Problem: unnecessary and deprecated diagnostics use their own highlight groups (`DiagnosticUnnecessary` and `DiagnosticDeprecated`) which override the typical severity-based highlight groups (like `DiagnosticUnderlineWarn`). This can be misleading, since diagnostics about unused variables which are warnings or errors, are shown like comments, since then only the `DiagnosticUnnecessary` highlight group is used. Users do not see the more eye-catching red/yellow highlight. Solution: Instead of overriding the highlight group to `DiagnosticUnnecessary` or `DiagnosticDeprecated`, set them in addition to the normal severity-based highlights.
* fix(diagnostics): showing stale diagnostics in handlers #35890Sergei Slipchenko2025-10-01
| | | | | | | | | | | | | | Fixes #35884 Problem: Since `once_buf_loaded` might call a callback passed to it at a later point (which is it's reason to exist) that callback might end up referring to stale diagnostics in a handler's `show` function. For example, if we first call `vim.diagnostic.set` for an unloaded buffer, then call `vim.diagnostic.reset` and only then load the buffer, we might still see diagnostics from `vim.diagnostic.set` call, which are stale at this point. Solution: only keep one autocommand from the most reset `show` call and delete it when `hide` is called.
* fix(diagnostic): show diagnostics on buffer load #35866Yochem van Rosmalen2025-09-22
| | | | | | | | Problem: Diagnostics set on unloaded buffers are not shown when the buffer loads. Solution: Use `once_buf_loaded()` to show the diagnostics on BufRead is the buffer is not yet loaded.
* docs(diagnostics): allow list of strings for vim.diagnostic.Opts.border (#35863)Karl Yngve Lervåg2025-09-22
| | | Type checkers complain if we pass a list of strings, but this should be allowed.
* refactor(lua): consistent use of local aliasesChristian Clason2025-08-28
|
* fix: don't use logical diagnostic position in `get_prev` and `get_next` #35282Sergei Slipchenko2025-08-11
| | | | | | | | | | | Problem: `vim.diagnostic.get_prev()` / `vim.diagnostic.get_next()` use logical diagnostic positions and consider extmark validity. `vim.diagnostic.get()` only uses original positions and doesn't care about extmark validity. This results in inconsistency between these APIs. Solution: use original positions in `vim.diagnostic.get_prev()` and `vim.diagnostic.get_next()` and don't consider extmark validity to match previous behavior, which is consistent with `vim.diagnostic.get`.
* fix(diagnostic): check if the buffer is loaded #35125Eisuke Kawashima2025-07-31
| | | | | fix #35116 Co-authored-by: Eisuke Kawashima <e-kwsm@users.noreply.github.com>
* fix(statusline): check buf valid before redraw #35123Anton Kastritskii2025-07-31
| | | fixes #35116
* feat(statusline): vim.diagnostic.status() #33723Anton Kastritskii2025-07-29
| | | | | | | | Problem: Not easy to get a status string for diagnostics. Solution: - Add vim.diagnostic.status(). - Add it to the default 'statusline'.