Commit Graph

211 Commits

Author SHA1 Message Date
Sergei Slipchenko
7a051a4c38 fix(diagnostics): avoid jumping to diagnostics in deleted ranges #35088
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.
2025-07-28 05:24:10 +00:00
Sergei Slipchenko
0a113013fb fix(diagnostics): position diagnostics using extmarks #34014
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`).
2025-07-25 07:56:50 -07:00
Mike
e4a100a1e1 fix(diagnostics): extend conversion support from/to quickfix format (#34006)
Use uppercase to check severity
Mark quickfix items as valid when converting from diagnostics
Support nr/code attribute between formats
2025-07-25 08:14:00 -05:00
Riley Bruins
68e316e3f9 feat(diagnostic): jump to related info location from open_float #34837
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.
2025-07-10 11:24:17 -07:00
Riley Bruins
2031287e93 feat(lsp): support diagnostic related information (#34474) 2025-07-07 13:05:02 -04:00
Lewis Russell
e34e2289c2 fix(diagnostic): fix flaky error 2025-07-04 18:03:41 +01:00
Bruce Wen
3594c213a7 fix(diagnostics): validate opts.signs #34565 2025-06-18 10:26:28 -07:00
Lewis Russell
3b6084ddf4 fix: type fixes
Type fixes caught by emmylua
2025-06-06 15:36:48 +01:00
Lewis Russell
2b21c9c23f fix(diagnostic): ensure autocmd always is always sent diagnostics 2025-06-05 13:02:56 +01:00
Lewis Russell
533cc0ab35 fix(vim.diagnostic): improve typing
Problem:

`vim.diagnostic.set()` doesn't actually accept a list of
`vim.Diagnostic` as internally `vim.diagnostic.set()` normalizes the
diagnostics and this normalization is assumed throughout the module.

Solution:

- Add a new type `vim.Diagnostic.Set` which is the input to `vim.diagnostic.set()`

- `col` is now an optional field and defaults to `0` to be consistent
  with `vim.diagnostic.match()`.

- Change `table.insert(t, x)` to `table[#table + 1] = x` for improved
  type checking.
2025-06-03 20:25:07 +01:00
Sergei Slipchenko
9641ad9369 fix(diagnostics): diagnostic just after EOL is not highlighted #34085
Fixes #34013

Problem:
when diagnostic is set right after EOL, underline handler looks
inconsistent compared to other handlers, visually underline is shown
starting from the next line. On top of that it's also inconsistent with
open_float and jump.

Solution:
clamp starting column position in underline handler to be right before
EOL to make it visible and consistent with other handlers, open_float
and jump.
2025-06-03 07:22:36 -07:00
Yochem van Rosmalen
62ba6e8a76 fix: use nvim namespace convention #34010 2025-05-22 03:40:08 -07:00
Maria José Solano
2e0158650a fix(diagnostic): accept multiple namespace in open_float() (#34073) 2025-05-21 10:54:43 -07:00
Rijul Kapoor
19efabafc5 fix(diagnostics): fixed virtual_text cursormoved autocmd error (#34017) 2025-05-21 10:20:37 -05:00
v1nh1shungry
dbe17da120 fix(diagnostic): deprecate float in vim.diagnostic.Opts.Jump (#34037) 2025-05-19 19:44:26 -07:00
Maria José Solano
4fae013a21 feat(diagnostic): add enabled filter (#33981) 2025-05-13 19:32:00 -07:00
Maria José Solano
2f24ae8de4 feat(diagnostic): add format option to setloclist/setqflist (#33977) 2025-05-12 20:50:37 -04:00
Maria José Solano
c681336e3c fix(diagnostic): accept multiple namespaces when setting loclist/qflist (#33982) 2025-05-12 20:13:26 -04:00
Maria José Solano
c65817774d feat(diagnostic): add on_jump callback option 2025-05-05 19:59:22 -07:00
Michael Clayton
d567f899ef fix(diagnostic): allow virtual_{lines,text} cursor exclusivity #33517
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.
2025-05-01 03:54:39 -07:00
Evgeni Chasnovski
71e133e5e6 docs(diagnostic): mention severity in Opts.VirtualLines (#33293)
Problem: `severity` field is recognized by
  `vim.diagnostic.Opts.VirtualLines`, but it is not explicitly
  documented.

Solution: document it.
2025-04-03 10:19:37 -05:00
Gregory Anders
9acb52c8f3 refactor(diagnostic)!: remove deprecated diagnostic APIs (#33072) 2025-03-26 13:56:23 -05:00
Mars Peng
f1fcf653cb fix(diagnostic): clear virtual_lines autocmd only for valid buf #32979 2025-03-19 05:27:20 -07:00
xzb
17c25a66fc fix(diagnostic): virtual lines should scroll horizontally 2025-03-16 12:31:29 +01:00
Jaehwang Jung
c78728a384 fix(diagnostic): clear autocmd only for valid buf (#32861) 2025-03-12 09:30:05 -05:00
James Trew
fb842dfc22 fix(diagnostic): virtual_lines diagnostic columns (#32703)
When multiple diagnostics appear on a single line, the virtual lines for
all diagnostics except the first were rendered with progressively fewer
columns.
2025-03-04 08:59:37 -06:00
Maria José Solano
0e8e4a07f5 fix(diagnostic): don't include diagnostic code when using custom formatter #32464 2025-02-16 12:13:29 -08:00
Maria José Solano
38a52caec0 feat(diagnostic): add current_line option for virtual_text handler 2025-02-05 15:27:09 +01:00
Maria José Solano
445ecca398 feat(diagnostic): format() can filter diagnostics by returning nil #32302 2025-02-03 00:54:31 -08:00
Maria José Solano
48e3ac60c6 perf(diagnostics): cache line diagnostics when current_line is set #32288
Compute the diagnostics per line when `show` is called, allowing for
O(1) access for the diagnostics to display when the cursor line or the
list of diagnostics haven't changed.
2025-02-02 03:40:43 -08:00
Tristan Knight
5bc948c050 fix(diagnostic): improve current_line refresh logic #32275
Problem:
The current implementation uses a global augroup for virtual lines in
diagnostics, which can lead to conflicts and unintended behavior when
multiple namespaces/buffers are involved.

Solution:
Refactor the code to use a namespace-specific augroup for virtual lines.
This ensures that each namespace has its own augroup.
Scope the clear commands to only the relevant buffer.
2025-02-02 01:56:01 -08:00
Lewis Russell
6aa42e8f92 fix: resolve all remaining LuaLS diagnostics 2025-01-27 16:37:50 +00:00
Maria José Solano
1759b7844a feat(diagnostic): virtual_lines #31959 2025-01-26 15:33:03 -08:00
georgev93
931ee5591f feat(extmarks): virtual text can be right-aligned, truncated #31921
Problem: Right aligned virtual text can cover up buffer text if virtual
text is too long

Solution: An additional option for `virt_text_pos` called
`eol_right_align` has been added to truncate virtual text if it would
have otherwise covered up buffer text. This ensures the virtual text
extends no further left than EOL.
2025-01-24 19:57:45 -08:00
Gregory Anders
51ccd12b3d fix(diagnostic)!: make virtual text handler opt-in (#32079)
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.
2025-01-18 07:43:21 -06:00
Maria José Solano
09e01437c9 refactor: use nvim.foo.bar format for autocommand groups 2025-01-14 21:25:25 -08:00
Maria José Solano
850084b519 refactor: use nvim.foo.bar format for namespaces 2025-01-14 19:55:29 -08:00
Gregory Anders
a119aae4d3 feat(diagnostic)!: filter diagnostics by severity before passing to handlers (#30070)
BREAKING CHANGE: This changes the list of diagnostics that are passed to
a diagnostic handler. If a handler is already filtering by severity
itself then this won't break anything, since the handler's filtering
will become a no-op. But handlers which depend on receiving the full
list of diagnostics may break.

Note that diagnostics are only filtered if the handler's configuration
has the `severity` option set. If `severity` is not set, the handler
still receives the full list of diagnostics.
2025-01-11 12:54:43 -06:00
Yorick Peterse
4cbeb6fa3c fix(diagnostic): silence :chistory #31701
vim.diagnostic.set_list() uses chistory to restore the actively selected
entry whenever necessary. This however also results in it displaying
some output in the message bar, but this output isn't useful (and can
even be distracting) when opening the quickfix window. This fixes this
by silencing the chistory command.
2024-12-23 11:57:15 -08:00
Juan Cruz De La Torre
6c975515c5 fix(diagnostic): vim.diagnostic.setqflist() opens loclist on first call #31585
Problem:
Regression from de794f2d24: `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.
2024-12-16 06:38:57 -08:00
Jeremy Fleischman
de794f2d24 fix(diagnostic): broken variable reference #31557 2024-12-12 02:41:57 -08:00
Jeremy Fleischman
5eda7aafe9 fix(diagnostic): setqflist() is stuck after vim.lsp.buf.document_symbol #31553
Previously, when updating the quickfix diagnostics list, we'd update it,
and then open the quickfix buffer, but there was no guarantee that the
quickfix buffer would be displaying the quickfix diagnostics list (it
could very possibly be displaying some other quickfix list!).

This fixes things so we first select the quickfix list before opening the
quickfix buffer. If `open` is not specified, the behavior is the same as
before: we update the diagnostics quickfix list, but do not navigate to
it.

fixes https://github.com/neovim/neovim/issues/31540
2024-12-11 17:32:07 -08:00
Jeremy Fleischman
21961967ff feat(diagnostic): update quickfix list by title #31486
Previously, there was a singleton diagnostics quickfix list. Now there's
effectively one per title (up to vim's internal limit on quickfix
lists).

Suggested by mfussenegger https://github.com/neovim/neovim/pull/30868#pullrequestreview-2385761374.
2024-12-11 17:29:54 -08:00
Lewis Russell
668d2569b4 refactor: add vim._resolve_bufnr 2024-12-07 16:58:40 +00:00
Jeremy Fleischman
fd902b1cb2 fix(diagnostic): only store quickfix id when creating a new one #31466
The old code would always update `_qf_id` with the current quickfix,
even if you're currently looking at a completely different,
non-diagnostics quickfix list. This completely defeats the intent of
<https://github.com/neovim/neovim/pull/30868>, whoops!
2024-12-05 13:59:33 -08:00
Jeremy Fleischman
7579af3c51 feat(diagnostic): vim.diagnostic.setqflist improvements #30868
1. Use the new "u" action to update the quickfix list so we don't lose
   our position in the quickfix list when updating it.
2. Rather than creating a new quickfix list each time, update the
   exiting one if we've already created one.
2024-12-04 07:49:57 -08:00
Mathias Fußenegger
99e7323aa3 feat(diagnostic): inherit parent 'path' option in open_float (#31273)
Diagnostics sometimes contain stack traces, it's useful being able to
use `CTRL-W F` on them to open related files from within the diagnostic
window.
2024-11-25 17:11:22 +01:00
Lewis Russell
1d4ba8c1ed fix: another round of type annotation fixes 2024-10-31 11:55:23 +00:00
Donatas
a9e725b26e feat(diagnostics)!: sort underline severity_sort (#30898)
feat(diagnostics)!: sort underline with severity_sort

BREAKING CHANGE: underline will be applied with a higher value than `vim.hl.priorities.diagnostics`
2024-10-27 11:36:39 -05:00
Lewis Russell
3572319b4c feat(vim.validate): improve fast form and deprecate spec form
Problem:

`vim.validate()` takes two forms when it only needs one.

Solution:

- Teach the fast form all the features of the spec form.
- Deprecate the spec form.
- General optimizations for both forms.
- Add a `message` argument which can be used alongside or in place
  of the `optional` argument.
2024-10-21 11:32:06 +01:00