aboutsummaryrefslogtreecommitdiff
path: root/test/functional/lua/diagnostic_spec.lua
Commit message (Collapse)AuthorAge
* fix(diagnostic): use logical positions for counted jumps #42394Volodymyr Chernetskyi4 days
| | | | | | | | | | | | | Problem: After edits move diagnostic ranges, counted jumps resume searching from their original positions. This can revisit the same diagnostic and hang the default first/last diagnostic mappings. Solution: Advance the search origin using the diagnostic's current logical position. Test forward and backward counted jumps after inserting or deleting a line, including jumps to the last or first diagnostic without wrapping. AI-assisted
* 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).
* fix(diagnostic): "Failed to delete autocmd" after noautocmd bwipeout #42303Justin M. Keyes9 days
| | | | | | | | | | | Problem: Handlers defer `show()` on unloaded buffers with a buffer-local BufRead autocmd whose id is stored per-namespace: - `noautocmd bwipeout` deletes the autocmd, so the next show/hide fails. - Showing another buffer in the same namespace cancels the pending show. Solution: Handlers skip unloaded buffers. The existing global BufRead autocmd shows cached diagnostics when the buffer loads.
* test: simplify functional test expectationsLewis Russell2026-10-05
| | | | | | | | | | | | Problem: Repeated default fields and field-by-field assertions obscure the values that each functional test is meant to check. Solution: Add eq_partial() to check selected record fields while preserving list length and order. Use local helpers to fill fixed expected defaults where tests need full equality. Keep explicit absence checks and test-specific values at the call sites. AI-assisted
* 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(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
* fix(diagnostic): don't accumulate BufRead autocmds for unloaded buffers #40869Nathan B.2026-08-13
| | | | | | | | | | | | | | | Problem: vim.diagnostic.set() defers extmark position computation for an unloaded buffer via a once=true BufRead autocmd, registering a new one on every call without replacing the previous one. Each pending autocmd also retains that call's diagnostics. Solution: Instead of registering an autocmd per set() call, register a single static BufRead autocmd that computes positions from the diagnostic cache for any buffer with cached diagnostics when it is read. This removes the per-call registration entirely (nothing left to accumulate) and means diagnostics cleared while the buffer was unloaded no longer produce stale extmarks.
* test(harness): migrate away from magic globalsJustin M. Keyes2026-07-21
| | | | | | | | | | | | | | | | | | | | | Problem: The magic globals `it`, `describe`, etc., are more trouble than they are worth. - Hooking into `after_each` requires `getfenv()` hacks. - They confuse luals/emmylua, because the top-level `.luarc.json` isn't merged with `test/.luarc.json` (apparently a luals limitation?) - They totally defeat discoverability because the user just has to "know" about the various magic symbols. So they harm DX, which means they serve no purpose at all. Solution: - Expose the test API from `testutil`, so tests can call `t.it()`, `t.describe()`, etc., in the conventional way. - Drop `getfenv()` hacks. - Drop the `setfenv()` injection in `load_chunk`. - Drop `test/_meta.lua`.
* fix(lsp): unclear error on malformed server responses #40422Kim A. Brandt2026-07-12
| | | | | | | | | Problem: Malformed server responses with `null` (vim.NIL) values, do not show clear error messages. Solution: Assert two known, specific cases, to avoid user confusion.
* 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".
* fix(diagnostic): stack _tags hl-groups in a single extmark #38654Artem Krinitsyn2026-06-02
| | | | | | | | | | | | Problem: Diagnostic highlight groups were applied by iterating and calling `vim.hl.range` for each group individually. That resulted in multiple extmarks with the same priority being created separately, which does not allow `DiagnosticUnnecessary` and `DiagnosticDeprecated` with matching options override `Diagnostic*` styling. Solution: Pass the list of hl-groups to `vim.hl.range` so they are applied together in the correct order.
* 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.
* fix(diagnostic): handle `signs = false` in `status()` (#39703)Maria Solano2026-05-09
|
* feat(diagnostic)!: deprecate `format` as a table #39603Yi Ming2026-05-06
|
* 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
* 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.
* 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().
* 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.
* docs: use "ev" convention in event-handlersJustin M. Keyes2026-03-12
| | | | | | | | | Problem: In autocmd examples, using "args" as the event-object name is vague and may be confused with a user-command. Solution: Use "ev" as the conventional event-object name.
* docs: api, messages, lsp, trustJustin M. Keyes2026-03-11
| | | | | gen_vimdoc.lua: In prepare for the upcoming release, comment-out the "Experimental" warning for prerelease features.
* 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(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.
* 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.
* 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'.
* fix(diagnostics): avoid jumping to diagnostics in deleted ranges #35088Sergei Slipchenko2025-07-28
| | | | | | | | | | | | Problem: diagnostic extmark used for positioning continues to exist after deleting a range containing it, so it's possible to jump to a next/previous diagnositc, which isn't visible in any way, including not being shown via `open_float`. Solution: enable `invalidate` flag when setting an extmark to be able to filter out diagnostics based on `invalid` flag when looking for next/previous diagnostic to jump to.
* fix(diagnostics): position diagnostics using extmarks #34014Sergei Slipchenko2025-07-25
| | | | | | | | | | | | | Problem: Diagnostic positions are not being updated after text changes, which means `vim.diagnostic.open_float` and `vim.diagnostic.jump` will work with outdated positions when text is changed until diagnostics are updated again (if ever). Solution: Create extmarks in `vim.diagnostic.set` and use their positions for `vim.diagnostic.open_float` and `next_diagnostic` (used by `vim.diagnostic.jump`, `vim.diagnostic.get_next` and `vim.diagnostic.get_prev`).
* feat(diagnostic): jump to related info location from `open_float` #34837Riley Bruins2025-07-10
| | | | | | This commit allows users to jump to the location specified in a diagnostic's `relatedInformation`, using `gf` from within the `open_float` window. The cursor need only be on line that displays the related info.
* fix(diagnostic): ensure autocmd always is always sent diagnosticsLewis Russell2025-06-05
|
* fix(diagnostic): accept multiple namespace in `open_float()` (#34073)Maria José Solano2025-05-21
|
* fix(diagnostics): fixed virtual_text cursormoved autocmd error (#34017)Rijul Kapoor2025-05-21
|
* feat(diagnostic): add `enabled` filter (#33981)Maria José Solano2025-05-13
|
* feat(diagnostic): add `format` option to `setloclist`/`setqflist` (#33977)Maria José Solano2025-05-12
|
* fix(diagnostic): accept multiple namespaces when setting loclist/qflist (#33982)Maria José Solano2025-05-12
|
* feat(diagnostic): add `on_jump` callback optionMaria José Solano2025-05-05
|
* fix(diagnostic): allow virtual_{lines,text} cursor exclusivity #33517Michael Clayton2025-05-01
| | | | | | | | | | | | | | | | | | | | Problem: virtual_text diagnostics are great when skimming a file, and virtual_lines are great when "zooming in" on a particular problem. Having both enabled results in duplicate diagnostics on-screen. Solution: This PR expands the behavior of `current_line` for virtual_text and virtual_lines by making `virtual_text.current_line = false` distinct from `nil`. If you set: vim.diagnostic.config({ virtual_text = { current_line = false }, virtual_lines = { current_line = true }, }) With this configuration, virtual_text will be used to display diagnostics until the cursor reaches the same line, at which point they will be hidden and virtual_lines will take its place.
* refactor(diagnostic)!: remove deprecated diagnostic APIs (#33072)Gregory Anders2025-03-26
|
* fix: temporarily disable 0.12 deprecation testsJustin M. Keyes2025-03-26
| | | | Re-enable these after release.
* fix(diagnostic): virtual_lines diagnostic columns (#32703)James Trew2025-03-04
| | | | | When multiple diagnostics appear on a single line, the virtual lines for all diagnostics except the first were rendered with progressively fewer columns.
* feat(diagnostic): add `current_line` option for `virtual_text` handlerMaria José Solano2025-02-05
|
* feat(diagnostic): format() can filter diagnostics by returning nil #32302Maria José Solano2025-02-03
|
* feat(diagnostic): virtual_lines #31959Maria José Solano2025-01-26
|
* fix(diagnostic)!: make virtual text handler opt-in (#32079)Gregory Anders2025-01-18
| | | | | | | | | | | Making this opt-out (on by default) was the wrong choice from the beginning. It is too visually noisy to be enabled by default. BREAKING CHANGE: Users must opt-in to the diagnostic virtual text handler by adding vim.diagnostic.config({ virtual_text = true }) to their config.
* fix(diagnostic): vim.diagnostic.setqflist() opens loclist on first call #31585Juan Cruz De La Torre2024-12-16
| | | | | | | | | | | | Problem: Regression from de794f2d2409: `vim.diagnostic.setqflist{open=true}` attempts to open the location list instead of the diagnostics quickfix list if it didn't exist before. This is because we are using `qf_id` to decide which to open, but `qf_id=nil` when there is no existing diagnostics quickfix list with a given title ("Diagnostics" by default). Solution: - Revert to using `loclist` to decide which to open. - Add tests.
* feat(diagnostics)!: sort underline severity_sort (#30898)Donatas2024-10-27
| | | | | feat(diagnostics)!: sort underline with severity_sort BREAKING CHANGE: underline will be applied with a higher value than `vim.hl.priorities.diagnostics`