aboutsummaryrefslogtreecommitdiff
path: root/test/functional/plugin/lsp/diagnostic_spec.lua
Commit message (Collapse)AuthorAge
* test: fix wrong order of args to eq(), neq() #41499zeertzjq2026-08-26
|
* feat(lsp): fallback to textDocument/formatting from vim.lsp.formatexpr #40079Marcus Caisey2026-08-18
| | | | | | | | | | | | | | | | Problem: With the addition of the `:help al` text object, you can now easily format the whole buffer with `gqal`. However, `vim.lsp.formatexpr` only uses `textDocument/rangeFormatting` which some language servers (like gopls) don't support. Solution: - Fall back to `textDocument/formatting` if the whole buffer is being formatted and the server doesn't support `textDocument/rangeFormatting`. - In theory, these two methods should return the same response if the whole buffer is being formatted, but I preserved the existing behaviour of prioritising `textDocument/rangeFormatting` in case that does not hold (i.e. LS bug). - Also: `vim.lsp.formatexpr` had no tests at all, so actually add tests for it.
* 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.
* fix(lsp): clear push diagnostics on detach #40634Oleh Volynets2026-07-08
| | | | | | | | | Problem: when an LS client detaches from the buffer, only pull diagnostics are cleared via capability framework. Push diagnostics remain stuck even when client stops/restarts. Solution: clear push diagnostics on client detach. ref #33864
* fix(lsp): refresh document-pull buffers on workspace/diagnostic/refresh #40623Caleb White2026-07-08
| | | | | | | | | | | | | | When a server supports both document and workspace pull diagnostics, `on_refresh` only dispatched a `workspace/diagnostic` request. The workspace response handler skips buffers with `pull_kind == "document"` (i.e. all buffers opened by the user), so their diagnostics went stale until the next `didChange` or `didOpen` event. Change `on_refresh` to always refresh document-pull buffers via `textDocument/diagnostic`, regardless of whether the server also supports workspace diagnostics. This ensures that opened buffers see updated diagnostics (e.g. after a save triggers an external tool like PHPStan) without requiring the user to re-enter insert mode.
* refactor(lsp): convert diagnostics to capability framework #40433jdrouhard2026-06-26
| | | | | | | | | | | | | | | | | | | | | | | | | Problem: Diagnostic tracking used a separate bufstates table and manual LspDetach/LspNotify autocmd management via _enable()/_refresh(), duplicating the lifecycle logic already provided by the Capability framework. This caused inconsistencies in how client attach/detach and buffer teardown were handled compared to other LSP features. Solution: Replace the ad-hoc bufstate tracking and _enable/_refresh pattern in vim.lsp.diagnostic with a proper Diagnostics subclass of Capability. This cleans up a few random places in the main lsp module and client module that were poking the diagnostics. It also fixes some pre-existing bugs and inconsistencies that were discovered: - Refresh diagnostics immediately on attach instead of lazily by the first didOpen/didChange notification - Fix Capability.active lookup in M.enable() to key by it_bufnr instead of the filter bufnr - Set lsp defaults before calling the _text_document_did_open_handler in Client:on_attach() so defaults are there before any lsp notification occurs - Log (and return early) on any error from a diagnostic request result instead of only returning early for server cancelled errors
* refactor: update usages of deprecated "buffer" param #39089Justin M. Keyes2026-04-15
|
* fix(diagnostics)!: restore `is_pull` namespace argument #38698Maria Solano2026-04-08
| | | | | | | | | | | | | | | | Problem: The current LSP diagnostic implementation can't differ between a pull diagnostic with no identifier and a set of diagnostics provided via push diagnostics. "Anonymous pull providers" are expected by the protocol https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#diagnosticOptions , depending on how the capability was registered: - Dynamic registrations have an identifier. - Static registrations will not. Solution: Restore the `is_pull` argument removed in https://github.com/neovim/neovim/pull/37938, keeping the identifier of pull diagnostic collections.
* refactor(lsp): replace _provider_value_get with _provider_foreachtris2032026-03-19
| | | | | | | | Introduce _provider_foreach to iterate over all matching provider capabilities for a given LSP method, handling both static and dynamic registrations. Update diagnostic logic and tests to use the new iteration approach, simplifying capability access and improving consistency across features.
* fix(lps): separate namespaces for pull/push diagnostics #37938Riccardo Mazzarini2026-02-26
| | | | | | | | | | | | | Problem: Regression from b99cdd0: Pull diagnostics (from `textDocument/diagnostic`) and push diagnostics (from `textDocument/publishDiagnostics`) use the same namespace, which is a problem when using language servers that publish two different sets of diagnostics on push vs pull, like rust-analyzer (see https://github.com/rust-lang/rust-analyzer/issues/18709#issuecomment-2551394047). Solution: Rename `is_pull` to `pull_id` which accepts a pull namespace instead of just a boolean.
* refactor(lsp): centralize provider capability resolution #37221Tristan Knight2026-02-14
| | | | | | | | - Refactor LSP client to use unified provider-based capability lookup for diagnostics and other features. - Introduce `_provider_value_get` to abstract capability retrieval, supporting both static and dynamic registrations. - Update diagnostic handling and protocol mappings to leverage provider-centric logic.
* test(lsp/diagnostic): clearing diagnostics #37759GenchoXD2026-02-08
| | | | | | | | | | | | Problem: Diagnostic lifecycle invariants (clearing on empty publish and buffer deletion) were previously implicit and not directly covered by functional tests, allowing regressions to go unnoticed. Solution: Add functional regression tests asserting that diagnostics are cleared when an LSP server publishes an empty diagnostic set and when the associated buffer is deleted. Assertions are scoped to the client diagnostic namespace and use public diagnostic APIs only.
* test(lsp/diagnostic_spec): fix creating unused clients (#37397)zeertzjq2026-01-15
| | | | | Fix #36793 Also fix some `integer?` -> `integer` conversion warnings while at it.
* Revert "feat(lsp): support `version` in `textDocument/publishDiagnostics` ↵Mathias Fußenegger2025-12-09
| | | | | | | | | #36754" (#36865) This reverts commit 03d6cf7aae4a72c7221a4fb8ebb14a7c8603ba18. See https://github.com/neovim/neovim/pull/36754#issuecomment-3626115697 The change was supposed to avoid showing stale diagnostics but had the opposite effect.
* feat(lsp): support dynamic registration for diagnostics (#36841)Tristan Knight2025-12-06
|
* refactor(lsp): fix lintPig Fang2025-12-05
|
* test(lsp): accept callback for diagnosticPig Fang2025-12-05
|
* refactor(lsp): fix lintPig Fang2025-12-05
|
* feat(lsp): support refreshing workspace diagnosticsPig Fang2025-12-05
|
* test(lsp): polish tests of refreshing diagnosticsPig Fang2025-12-05
|
* test(lsp): update test namePig Fang2025-12-05
|
* feat(lsp): support diagnostic refresh requestPig Fang2025-12-05
|
* feat(lsp): support `version` in `textDocument/publishDiagnostics` #36754Riley Bruins2025-11-29
| | | | This commit makes it so that push diagnostics received for an outdated document version are ignored.
* feat(lsp): deprecate `vim.lsp.stop_client` (#36459)Olivia Kinnear2025-11-10
| | | | | * feat(lsp): deprecate `vim.lsp.stop_client` * fix(tests): fix nil variable in diagnostic_spec.lua
* fix(lsp): deprecate `vim.lsp.protocol.Methods` (#35998)Maria Solano2025-10-04
|
* test: don't call clear() in both before_each() and after_each() (#35901)zeertzjq2025-09-24
|
* feat(lsp): diagnostic related documents supportRiley Bruins2025-07-21
|
* fix(lsp): store result id for unchanged diagnostic reportsRiley Bruins2025-07-21
| | | | | | | | | **Problem:** For unchanged document diagnostic reports, the `resultId` is ignored completely, even though it should still be saved for the request (in fact, the spec marks it as mandatory for unchanged reports, so it should be extra important). **Solution:** Always store the `resultId`.
* fix(lsp): improper diagnostic end_col computationRiley Bruins2025-05-03
| | | | | | | | **Problem:** For multiline diagnostics, the end column was improperly calculated by checking the byte index of the character position on the *start* line. **Solution:** Calculate the byte index for end_col using the *end* line.
* perf(lsp): include `previousResultId` in `DocumentDiagnosticParams` #32887Yi Ming2025-04-26
| | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: Users of the Roslyn (C#) LSP have encountered significant delays when retrieving pull diagnostics in large documents while using Neovim. For instance, diagnostics in a 2000-line .cs file can take over 20 seconds to display after edits in Neovim, whereas in VS Code, diagnostics for the same file are displayed almost instantly. As [mparq noted](https://github.com/seblj/roslyn.nvim/issues/93#issuecomment-2508940330) in https://github.com/seblj/roslyn.nvim/issues/93, VS Code leverages additional parameters specified in the [LSP documentation for textDocument/diagnostic](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#documentDiagnosticParams), specifically: - previousResultId - identifier Solution: When requesting diagnostics, Neovim should include the `previousResultId` and `identifier` parameters as part of the request. These parameters enable the server to utilize caching and return incremental results. Support for maintaining state is already present in the [textDocument/semanticTokens implementation](https://github.com/neovim/neovim/blob/8f84167c30692555d3332565605e8a625aebc43c/runtime/lua/vim/lsp/semantic_tokens.lua#L289). A similar mechanism can be implemented in `textDocument/diagnostic` handler.
* feat(lsp): deprecate vim.lsp.start_client #31341Maria José Solano2024-12-04
| | | | | | | | Problem: LSP module has multiple "start" interfaces. Solution: - Enhance vim.lsp.start - Deprecate vim.lsp.start_client
* fix(lsp): retrigger diagnostics request on server cancellation (#31345)Gregory Anders2024-11-25
| | | Co-authored-by: Jesse <github@jessebakker.com>
* feat(lsp)!: remove client-server handlers from vim.lsp.handlersLewis Russell2024-11-01
| | | | | | | | | | - Partition the handlers in vim.lsp.handlers as: - client to server response handlers (RCS) - server to client request handlers (RSC) - server to client notification handlers (NSC) Note use string indexes instead of protocol.methods for improved typing in LuaLS (tip: use hover on RCS, RSC or NSC).
* refactor(lsp): drop str_byteindex/str_utfindex wrappers #30915Tristan Knight2024-10-26
| | | | | * deprecate old signatures * move to new str_byteindex/str_utfindex signature * use single-underscore name (double-underscore is reserved for Lua itself)
* test: support upvalues in exec_luaLewis Russell2024-09-21
|
* refactor(lsp): add test case for default diagnostic severityMathias Fussenegger2024-08-02
| | | | | | | | See https://github.com/microsoft/language-server-protocol/pull/1978 If the severity is not specified by the server, error should be used. This was already the case because it matches the vim.diagnostic default. This only adds a test case for it.
* fix(lsp): don't send foreign diagnostics to servers in buf.code_action (#29501)Mathias Fußenegger2024-08-01
| | | | | | | `buf.code_action` always included diagnostics on a given line from all clients. Servers should only receive diagnostics they published, and in the exact same format they sent it. Should fix https://github.com/neovim/neovim/issues/29500
* test: improve test conventionsdundargoc2024-04-23
| | | | | | | | | Specifically, functions that are run in the context of the test runner are put in module `test/testutil.lua` while the functions that are run in the context of the test session are put in `test/functional/testnvim.lua`. Closes https://github.com/neovim/neovim/issues/27004.
* refactor(test): inject after_each differentlyLewis Russell2024-04-10
|
* test: improve test conventionsdundargoc2024-04-08
| | | | Work on https://github.com/neovim/neovim/issues/27004.
* test: correct order of arguments to eq() (#27816)zeertzjq2024-03-11
|
* feat(lsp): deprecate severity_limitLewis Russell2024-02-08
| | | | | | | | | | | Problem: `vim.lsp.diagnostic.on_diagnostic` accepts an undocumented severity_limit option which is widely used. Solution: Deprecate it in favour of `{min = severity}` used in `vim.diagnostic`. Since this is undocumented, the schedule for removal is accelerated to 0.11.
* refactor: format test/*Justin M. Keyes2024-01-03
|
* fix(lsp): only disable inlay hints / diagnostics if no other clients are ↵Chris AtLee2023-08-31
| | | | | | | | | | | | | | | | | | | connected (#24535) This fixes the issue where the LspNotify handlers for inlay_hint / diagnostics would end up refreshing all attached clients. The handler would call util._refresh, which called vim.lsp.buf_request, which calls the method on all attached clients. Now util._refresh takes an optional client_id parameter, which is used to specify a specific client to update. This commit also fixes util._refresh's handling of the `only_visible` flag. Previously if `only_visible` was false, two requests would be made to the server: one for the visible region, and one for the entire file. Co-authored-by: Stanislav Asunkin <1353637+stasjok@users.noreply.github.com> Co-authored-by: Mathias Fußenegger <mfussenegger@users.noreply.github.com>
* feat(lsp): implement textDocument/diagnostic (#24128)Chris AtLee2023-07-20
|
* feat(diagnostic): add support for tagsLewis Russell2023-03-30
| | | | | | The LSP spec supports two tags that can be added to diagnostics: unnecessary and deprecated. Extend vim.diagnostic to be able to handle these.
* refactor(lsp): use autocmd api (#19407)ii142022-07-17
| | | | | | | * refactor(lsp): use autocmd api * refactor(lsp): inline BufWritePost and VimLeavePre callbacks
* fix(lsp): fix unnecessary buffers being added on empty diagnostics (#18275)ii142022-04-26
| | | | | Some language servers send empty `textDocument/publishDiagnostics` messages after indexing the project with URIs corresponding to unopened buffers. This commit guards against opening buffers corresponding to empty diagnostics.
* feat(diagnostic): add "code" to the diagnostic structure (#17510)David Shen2022-03-02
|