aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/diagnostic.lua
Commit message (Collapse)AuthorAge
* 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
|
* perf(diagnostics): cache line diagnostics when `current_line` is set #32288Maria José Solano2025-02-02
| | | | | 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.
* fix(diagnostic): improve current_line refresh logic #32275Tristan Knight2025-02-02
| | | | | | | | | | | 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.
* fix: resolve all remaining LuaLS diagnosticsLewis Russell2025-01-27
|
* feat(diagnostic): virtual_lines #31959Maria José Solano2025-01-26
|
* feat(extmarks): virtual text can be right-aligned, truncated #31921georgev932025-01-24
| | | | | | | | | 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.
* 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.
* refactor: use nvim.foo.bar format for autocommand groupsMaria José Solano2025-01-14
|
* refactor: use nvim.foo.bar format for namespacesMaria José Solano2025-01-14
|
* feat(diagnostic)!: filter diagnostics by severity before passing to handlers ↵Gregory Anders2025-01-11
| | | | | | | | | | | | | (#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.
* fix(diagnostic): silence :chistory #31701Yorick Peterse2024-12-23
| | | | | | | 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.
* 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.
* fix(diagnostic): broken variable reference #31557Jeremy Fleischman2024-12-12
|
* fix(diagnostic): setqflist() is stuck after vim.lsp.buf.document_symbol #31553Jeremy Fleischman2024-12-11
| | | | | | | | | | | | | 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
* feat(diagnostic): update quickfix list by title #31486Jeremy Fleischman2024-12-11
| | | | | | | 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.
* refactor: add vim._resolve_bufnrLewis Russell2024-12-07
|
* fix(diagnostic): only store quickfix id when creating a new one #31466Jeremy Fleischman2024-12-05
| | | | | | 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!
* feat(diagnostic): vim.diagnostic.setqflist improvements #30868Jeremy Fleischman2024-12-04
| | | | | | 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.
* feat(diagnostic): inherit parent 'path' option in open_float (#31273)Mathias Fußenegger2024-11-25
| | | | | 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.
* fix: another round of type annotation fixesLewis Russell2024-10-31
|
* 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`
* feat(vim.validate): improve fast form and deprecate spec formLewis Russell2024-10-21
| | | | | | | | | | | | | | 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.
* refactor: rename vim.highlight => vim.hlJustin M. Keyes2024-10-21
| | | | | | | | | | | | Problem: - `vim.highlight` module does not follow `:help dev-name-common`, which documents the name for "highlight" as "hl". - Shorter names are usually preferred. Solution: Rename `vim.highlight` to `vim.hl`. This is not a breaking change until 2.0 (or maybe never).
* perf(validate): use lighter versionLewis Russell2024-10-17
| | | | | - Also fix `vim.validate()` for PUC Lua when showing errors for values that aren't string or number.
* fix(diagnostic): correct `severity` type on `setqflist`, `setloclist` (#30506)Nathan Smith2024-09-25
| | | fix(diagnostic): correct severity type on setqflist, setloclist
* fix(diagnostic): fix backwards compatibility for goto_next and goto_prev ↵Max Coplan2024-07-09
| | | | (#29593)
* fix(diagnostic): make docs agree with code (#29561)Peter Aronoff2024-07-04
| | | | | | | | | | | Problem: the code and docs for vim.diagnostic.JumpOpts.float send mixed signals about what the default should be. When the option is first set, in the global_diagnostic_options table, the comment clearly says that the default is false. Later in the code, in goto_diagnostic, there's a line that sets the default to true if no default is present. Finally, the docs say that the default is true. Solution: Change the docs to reflect the new default of false and fix the goto_diagnostic function.
* refactor: use `vim._with` where possibledundargoc2024-06-28
| | | | | This mostly means replacing `nvim_buf_call` and `nvim_win_call` with `vim._with`.
* fix(diagnostics): don't apply extmarks to invalid lines #29321Riley Bruins2024-06-19
| | | | | | | | | | | Problem: If there are errors in the last line of a buffer, something like `Gdk` or `G2k3J` will produce an error (at least with `lua_ls`): Error executing vim.schedule lua callback: .../neovim/share/nvim/runtime/lua/vim/diagnostic.lua:1446: Invalid 'line': out of range Solution: Only set extmarks if the target buffer line still exists
* docs: misc (#28837)dundargoc2024-06-07
| | | | | | | | | | | | | | | Co-authored-by: Danymat <d.danymat@gmail.com> Co-authored-by: Gregory Anders <greg@gpanders.com> Co-authored-by: Jakub Okoński <jakub@okonski.org> Co-authored-by: John L. Villalovos <john@sodarock.com> Co-authored-by: Maria José Solano <majosolano99@gmail.com> Co-authored-by: Michaili K <git@michaili.dev> Co-authored-by: TheLeoP <eugenio2305@hotmail.com> Co-authored-by: Tobias Schmitz <tobiasschmitz2001@gmail.com> Co-authored-by: W20MC <157727813+W20MC@users.noreply.github.com> Co-authored-by: Will Hopkins <willothyh@gmail.com> Co-authored-by: Yifan Hu <141280278+b0ae989c@users.noreply.github.com> Co-authored-by: glepnir <glephunter@gmail.com> Co-authored-by: prljav <74116121+prljav@users.noreply.github.com>
* fix(diagnostic): fix float scope filtering (#29134)Andre Toerien2024-06-04
|
* refactor(lua): use tuple syntax everywhere #29111Ilia Choly2024-06-04
|
* feat: add "jump" options to vim.diagnostic.config() (#29067)Gregory Anders2024-05-28
| | | | | | | | | | | | | | | | | | | | | | | | | Problem: There is no easy way to configure the behavior of the default diagnostic "jump" mappings. For example, some users way want to show the floating window, and some may not (likewise, some way want to only move between warnings/errors, or disable the "wrap" parameter). Solution: Add a "jump" table to vim.diagnostic.config() that sets default values for vim.diagnostic.jump(). Alternatives: Users can override the default mappings to use the exact options to vim.diagnostic.jump() that they want, but this has a couple issues: - While the default mappings are not complicated, they are also not trivial, so overriding them requires users to understand implementation details (specifically things like setting "count" properly). - If plugins want to change the default mappings, or configure the behavior in any way (e.g. floating window display), it becomes even harder for users to tweak specific behavior. vim.diagnostic.config() already works quite well as the "entry point" for tuning knobs with diagnostic UI elements, so this fits in nicely and composes well with existing mental models and idioms.
* feat(diagnostic): add vim.diagnostic.jump() (#26745)Gregory Anders2024-05-28
| | | | | | | | | | | | Deprecate vim.diagnostic.goto_prev() and vim.diagnostic.goto_next() in favor of a unified vim.diagnostic.jump() interface. We cannot name the function "goto()" because some of our tooling (luacheck and stylua) fail to parse it, presumably because "goto" is a keyword in newer versions of Lua. vim.diagnostic.jump() also allows moving to a specific diagnostic and moving by multiple diagnostics at a time (useful for creating mappings that use v:count).
* fix: change deprecation presentationdundargoc2024-05-24
| | | | | | | | | | | | | | Deprecation with vim.deprecate is currently too noisy. Show the following warning instead: [function] is deprecated. Run ":checkhealth vim.deprecated" for more information. The important part is that the full message needs to be short enough to fit in one line in order to not trigger the "Press ENTER or type command to continue" prompt. The full information and stack trace for the deprecated functions will be shown in the new healthcheck `vim.deprecated`.
* fix(diagnostic): show backtrace for deprecation warningsJongwook Choi2024-05-20
| | | | | | | | | | | | Problem: On nvim 11.0-dev, deprecation warnings due to an use of hard-deprecated APIs such as: - `vim.diagnostic.disable()` - `vim.diagnostic.is_disabled()` etc. are not accompanied by backtrace information. It makes difficult for users to figure out which lines or which plugins are still using deprecated APIs. Solution: use `backtrace = true` in vim.deprecate() call.
* docs: misc (#28761)dundargoc2024-05-16
| | | Co-authored-by: Florian Zeitz <florob@babelmonkeys.de>
* feat(diagnostic): revert default behaviour of goto_next/prev()Lewis Russell2024-04-30
| | | | | | | | | | | | | | | | | Follow-up to #28490 Problem: The new behaviour of goto_next/prev() of navigating to the next highest severity doesn't work well when diagnostic providers have different interpretations of severities. E.g. the user may be blocked from navigating to a useful LSP warning, due to some linter error. Solution: The behaviour of next highest severity is now a hidden option `_highest = true`. We can revisit how to integrate this behaviour during the 0.11 cycle.
* feat(defaults): visual CTRL-R for LSP mappings #28537Justin M. Keyes2024-04-28
| | | | | | | | | | Problem: The new LSP "refactor menu" keybinding "crr" is also defined in visual mode, which overlaps with the builtin "c". Solution: Use CTRL-R instead of "crr" for visual mode. fix #28528
* fix(diagnostic): get border from config (#28531)glepnir2024-04-28
| | | | Co-authored-by: Justin M. Keyes <justinkz@gmail.com> Co-authored-by: Gregory Anders <greg@gpanders.com>
* fix(diagnostic): invalid col number compare in next_diagnostic (#28397)Raphael2024-04-27
| | | | | Problem: when line is blank link then there will got an invalid column number in math.min compare. Solution: make sure the min column number is 0 not an illegal number.
* feat(diagnostic): goto functions jump to highest severity (#28490)Gregory Anders2024-04-25
| | | | | When the "severity" option is nil, vim.diagnostic.goto_next() and vim.diagnostic.goto_prev() jump to the next diagnostic with the highest severity.
* perf(diagnostic): avoid table copies to filter by severity (#28491)Mathias Fußenegger2024-04-24
| | | | | | Instead of adding all diagnostics matching lnum filters to a table, and then copying that table to another table while applying the severity filter, this changes the flow to only add diagnostics matching both filters in the first pass.
* fix(diagnostic): vim.diagnostic.get(…,{lnum=…}) on multi-line diagnostic ↵Raphael2024-04-23
| | | | | | | | #28273 Problem: vim.diagnostic.get(…,{lnum=…}) does not match multi-line diagnostics. Solution: add end_lnum support.
* fix(diagnostic): open_float on multi-line diagnostics #28301Raphael2024-04-23
| | | | | Problem: when diagnostic have a range of line, open_float not work. Solution: filter diagnostic by line number range.
* refactor(lua): rename tbl_islist => islistJustin M. Keyes2024-04-21
| | | | ref #24572
* feat(lua): enable(enable:boolean, filter:table) #28374Justin M. Keyes2024-04-18
| | | | | | | | | | | | | Problem: We need to establish a pattern for `enable()`. Solution: - First `enable()` parameter is always `enable:boolean`. - Update `vim.diagnostic.enable()` - Update `vim.lsp.inlay_hint.enable()`. - It was not released yet, so no deprecation is needed. But to help HEAD users, it will show an informative error. - vim.deprecate(): - Improve message when the "removal version" is a *current or older* version.
* feat(diagnostic): enable(…, opts)Justin M. Keyes2024-04-15
| | | | | | | | | | Problem: vim.diagnostic.enable() does not match the signature of vim.lsp.inlay_hint.enable() Solution: - Change the signature so that the first 2 args are (bufnr, enable). - Introduce a 3rd `opts` arg. - Currently it only supports `opts.ns_id`.
* feat(diagnostic): is_enabled, enable(…, enable:boolean)Justin M. Keyes2024-04-15
| | | | | | | | | | | | | | | | | | | | Problem: `vim.diagnostic.is_disabled` and `vim.diagnostic.disable` are unnecessary and inconsistent with the "toggle" pattern (established starting with `vim.lsp.inlay_hint`, see https://github.com/neovim/neovim/pull/25512#pullrequestreview-1676750276 As a reminder, the rationale is: - we always need `enable()` - we always end up needing `is_enabled()` - "toggle" can be achieved via `enable(not is_enabled())` - therefore, - `toggle()` and `disable()` are redundant - `is_disabled()` is a needless inconsistency Solution: - Introduce `vim.diagnostic.is_enabled`, and `vim.diagnostic.enable(…, enable:boolean)` - Note: Future improvement would be to add an `enable()` overload `enable(enable:boolean, opts: table)`. - Deprecate `vim.diagnostic.is_disabled`, `vim.diagnostic.disable`