summaryrefslogtreecommitdiffstatshomepage
path: root/runtime/lua/vim/lsp/client.lua
AgeCommit message (Collapse)AuthorFiles
2026-04-24fix(lsp): handle self-mapped methods in supports_method #39383nightlyTristan Knight1
Problem: The LSP client incorrectly checks for server capabilities when determining support for self-mapped methods (e.g., 'shutdown'), which do not have corresponding capabilities in the server's response. This leads to false negatives when checking if such methods are supported. This was handled correctly for dynamic registrations, but not for static. Methods such as 'shutdown', do not have a related server capability and should be assumed to be supported. Solution: Update the `supports_method` logic to always return true for self-mapped methods.
2026-04-18docs: misc #39045Justin M. Keyes1
2026-04-16test: lint naming conventions #39117Justin M. Keyes1
Problem: Naming conventions are not automatically checked. Solution: Add a check to the doc generator. Eventually we should extract this somehow, but that will require refactoring the doc generator... Note: this also checks non-public functions, basically anything that passes through `gen_eval_files.lua` and `gen_vimdoc.lua`. And that's a good thing.
2026-04-14docs: lsp, options, api #38980Justin M. Keyes1
docs: lsp, options - revert bogus change to `_meta/builtin_types.lua` from 3a4a66017b74 Close #38991 Co-authored-by: David Mejorado <david.mejorado@gmail.com>
2026-04-08feat(api): rename buffer to buf #35330Jordan1
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>
2026-04-02refactor(lsp): remove implicit rpc error tostring #38707Yi Ming1
Problem: LSP error responses implicitly rely on a custom `__tostring` function (`vim.lsp.rpc.format_rpc_error`) for formatting. This causes errors that are not created via `vim.lsp.rpc.error` to behave inconsistently with those that are. Furthermore, we usually use `log.error` to print these errors, which uses `vim.inspect` under the hood, so the custom `__tostring` provides little benefit. This increases the difficulty of refactoring the code, as it tightly couples RPC error handling with the LSP. Solution: Convert every potential `__tostring` call to an explicit one. Since we don't describe this behavior in the documentation, this should not be a breaking change.
2026-04-01docs: misc #38584Justin M. Keyes1
2026-04-01Merge #38560 refactor vim.lsp.rpcJustin M. Keyes1
2026-03-30docs: fix syntax errors in examples #38606skewb1k1
2026-03-30refactor(lsp): merge `vim.lsp.rpc.Client` and `vim.lsp.rpc.PublicClient`Yi Ming1
2026-03-21feat(lua): replace `buffer` with `buf` in vim.keymap.set/del #38360skewb1k1
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`.
2026-03-19fix(lsp): handle providers without subcapabilitiestris2031
Previously, the LSP client assumed all providers had subcapabilities, which could cause issues when a provider did not. This change adds a check for the presence of subcapabilities before attempting to access them, ensuring correct handling of both cases. This improves compatibility with servers that register providers without additional capabilities.
2026-03-19refactor(lsp): replace _provider_value_get with _provider_foreachtris2031
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.
2026-03-18feat(lsp): migrate `document_color` to capability framework (#38344)Maria Solano1
* feat(lsp): migrate `document_color` to capability framework * feat(lsp): use `vim.Range` in `document_color` module
2026-03-12refactor: integer functions, optimize asserts #34112Lewis Russell1
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
2026-03-11docs: api, messages, lsp, trustJustin M. Keyes1
gen_vimdoc.lua: In prepare for the upcoming release, comment-out the "Experimental" warning for prerelease features.
2026-02-14refactor(lsp): centralize provider capability resolution #37221Tristan Knight1
- 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.
2026-02-03feat(lsp): support range + full semantic token requests #37611jdrouhard1
From the LSP Spec: > There are two uses cases where it can be beneficial to only compute > semantic tokens for a visible range: > > - for faster rendering of the tokens in the user interface when a user > opens a file. In this use case, servers should also implement the > textDocument/semanticTokens/full request as well to allow for flicker > free scrolling and semantic coloring of a minimap. > - if computing semantic tokens for a full document is too expensive, > servers can only provide a range call. In this case, the client might > not render a minimap correctly or might even decide to not show any > semantic tokens at all. This commit unifies the usage of range and full/delta requests as recommended by the LSP spec and aligns neovim with the way other LSP clients use these request types for semantic tokens. When a server supports range requests, neovim will simultaneously send a range request and a full/delta request when first opening a file, and will continue to issue range requests until a full response is processed. At that point, range requests cease and full (or delta) requests are used going forward. The range request should allow servers to return a result faster for quicker highlighting of the file while it works on the potentially more expensive full result. If a server decides the full result is too expensive, it can just error out that request, and neovim will continue to use range requests. This commit also fixes and cleans up some other things: - gen_lsp: registrationMethod or registrationOptions imply dynamic registration support - move autocmd creation/deletion to on_attach/on_detach - debounce requests due to server refresh notifications - fix off by one issue in tokens_to_ranges() iteration
2026-02-03fix(lsp): avoid scheduling client deletion before LspNotify #37685Yi Ming1
Problem: `Client.on_exit` runs `Client._on_detach` and the client removal logic within two separate `vim.schedule` sequentially. However, since `Client._on_detach` executes `LspNotify` inside `vim.schedule`, this causes `LspNotify` to be executed after the client removal, which is scheduled first. At that point, a valid `Client` can no longer be retrieved within the autocmd callback. Solution: Put the client deletion inside the `vim.schedule` call.
2026-01-28fix(types): add missing @return annotationsJosh Cooper1
2026-01-27feat(lsp): semantic token range improvements #37451jdrouhard1
* cache all tokens from various range requests for a given document version - all new token highlights are merged with previous highlights to maintain order and the "marked" property - this allows the tokens to stop flickering once they've loaded once per document version * abandon the processing coroutine if the request_id has changed instead of relying only on the document version - this will improve efficiency if a new range request is made while a previous one was processing its result * apply new highlights from processing coroutine directly to the current result when the version hasn't changed - this allows new highlights to be immediately drawable once they've processed instead of waiting for the whole response to be processed at once * rpc layer was changed to provide the request ID back in success callbacks, which is then provided as a request_id field on the handler context to lsp handlers
2026-01-12docs: misc (#37281)zeertzjq1
Close #37289 Close #37348 Co-authored-by: Marc Jakobi <marc@jakobi.dev> Co-authored-by: Anton Kesy <anton@kesy.de>
2026-01-07docs: misc (#37280)zeertzjq1
Close #36806 Close #36812 Close #37003 Close #37016 Close #37038 Close #37039 Close #37157 Close #37185 Close #37213 Co-authored-by: saroj_r <sarojregmi.official@gmail.com> Co-authored-by: Olivia Kinnear <git@superatomic.dev> Co-authored-by: Igor <igorlfs@ufmg.br> Co-authored-by: Justin Roberts <JustinEdwardLeo@gmail.com> Co-authored-by: "Mike J. McGuirk" <mike.j.mcguirk@gmail.com> Co-authored-by: Aymen Hafeez <49293546+aymenhafeez@users.noreply.github.com> Co-authored-by: Peter Cardenas <16930781+PeterCardenas@users.noreply.github.com> Co-authored-by: DrNayak2306 <dhruvgnk.work@gmail.com>
2026-01-02fix(lsp): `:lsp restart` restarts on client exit #37125Olivia Kinnear1
Problem: `:lsp restart` detects when a client has exited by using the `LspDetach` autocommand. This works correctly in common cases, but breaks when restarting a client which is not attached to any buffer. It also breaks if a client is detached in between `:lsp restart` and the actual stopping of the client. Solution: Move restart logic into `vim/lsp/client.lua`, so it can hook in to `_on_exit()`. The public `on_exit` callback cannot be used for this, as `:lsp restart` needs to ensure the restart only happens once, even if the command is run multiple times on the same client.
2026-01-02fix(lsp): improve dynamic registration handling #37161Tristan Knight1
Work on #37166 - Dynamic Registration Tracking via Provider - Supports_Method - Multiple Registrations - RegistrationOptions may dictate support for a method
2025-12-15fix(lsp): correct capability checks for dynamic registration (#36932)Tristan Knight1
Refactor capability checks in Client:_supports_registration and Client:supports_method to properly handle dynamicRegistration and unknown methods. Now, dynamic capabilities are checked before assuming support for unknown methods, ensuring more accurate LSP feature detection.
2025-12-06docs: miscJustin M. Keyes1
fix https://github.com/neovim/neovim.github.io/issues/419 Co-authored-by: Rob Pilling <robpilling@gmail.com>
2025-12-06refactor(lsp): unify capability checks and registration #36781Tristan Knight1
Problem: Our LSP type system didnt have a concept of RegistrationMethods, this is where the method to dynamically register for a capability is sent to a different method endpoint then is used to call it. Eg `textDocument/semanticTokens` rather than the specific full/range/delta methods Solution: Extended generator to create `vim.lsp.protocol.Methods.Registration` with these registration methods. Also extend `_request_name_to_client_capability` to cover these methods. Adjust typing to suit
2025-12-04feat(lsp): `Client:stop()` defaults to `exit_timeout` #36783Olivia Kinnear1
Problem: If a `vim.lsp.config` explicitly sets `exit_timeout`, that indicates the config wants that behavior for most usages of `:stop()`. Solution: Update `:stop()` to use `force=exit_timeout` if `force` was not explicitly passed.
2025-12-03fix(lsp): default ClientConfig.exit_timeout to false #36811Olivia Kinnear1
2025-12-03fix(lsp): close timer when client exits (#36795)zeertzjq1
Also, don't start the timer at all when a previous shutdown failed, as in this case a forced shutdown is used and no timer is needed. This fixes most of the delays caused by #36750. The delays caused by #36378 still seem to remain.
2025-11-30feat(lsp): graduate ClientConfig `exit_timeout` #36750Olivia Kinnear1
Problem: The `flags` field calls its sub-fields "experimental". But `exit_timeout` is now used for multiple purposes. Solution: Graduate `exit_timeout` to a top-level ClientConfig field.
2025-11-30feat(lsp): semanticTokens/range #36705Tristan Knight1
Problem: Nvim supports `textDocument/semanticTokens/full` and `…/full/delta` already, but most servers don't support `…/full/delta` and Nvim will try to request and process full semantic tokens response on every buffer change. Even though the request is debounced, there is noticeable lag if the token response is large (in a big file). Solution: Support `textDocument/semanticTokens/range`, which requests semantic tokens for visible screen only.
2025-11-05fix(lsp): don't immediately force shutdown when using a timeout (#36455)Maria Solano1
2025-11-01feat(lsp): support auto-force escalation in client stop (#36378)Maria Solano1
2025-10-24docs: types, news, lua-pluginJustin M. Keyes1
- mention "lua_ls", not "luals". https://github.com/neovim/neovim/discussions/36182 Co-authored-by: Maria Solano <majosolano99@gmail.com>
2025-10-16fix(lsp): replace `string` types with LSP method alias type annotations ↵David1
where appropriate. (#36180) fix(lsp): replace `string` types with LSP method alias where appropriate
2025-10-14revert "fix(lsp): _get_workspace_folders does not handle root_dir() ↵Mathias Fußenegger1
function" #36183 This reverts commit 97ab24b9c7d9327740f0692f8076fed5737a52dc. See discussion in https://github.com/neovim/neovim/pull/36071
2025-10-11fix(lsp): _get_workspace_folders does not handle root_dir() function #36071atusy1
* fix(lsp): type of root_dir should be annotated with string|fun|nil * feat(lsp): support root_dir as function in _get_workspace_folders * feat(lsp): let checkhealth support root_dir() function Examples: vim.lsp: Active Clients ~ - lua_ls (id: 1) - Version: <Unknown> - Root directories: ~/foo/bar ~/dev/neovim Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
2025-10-07fix(lsp): typos in method names #36077Igor Lacerda1
2025-10-04fix(lsp): deprecate `vim.lsp.protocol.Methods` (#35998)Maria Solano1
2025-09-16fix(lsp): restore Client:stop() force-stopping behavior (#35800)zeertzjq1
This fixes a regression from #33796. I tried for several hours and cannot write a working test for this, but this does fix the following warning in tests run with ASAN or TSAN: -------- Running tests from test/functional/plugin/lsp_spec.lua RUN T4667 LSP server_name specified start_client(), stop_client(): 114.00 ms OK RUN T4668 LSP server_name specified stop_client() also works on client objects: 97.00 ms OK RUN T4669 LSP server_name specified does not reuse an already-stopping client #33616: 31.00 ms OK nvim took 2022 milliseconds to exit after last test This indicates a likely problem with the test even if it passed!
2025-09-15fix(lsp): avoid re-enabling `document_color` on `registerCapability` (#35774)skewb1k1
Problem: The registerCapability handler re-enables document_color, making it impossible to disable it in LspAttach. Solution: Enable it once on initialization and avoid re-enabling on registerCapability.
2025-09-08fix(lsp): check if buffer is valid in scheduled client:on_attach() #35672notomo1
Problem: lsp._capability.is_enabled() can raise error if buffer is invalid in client:on_attach(). - error ``` ./build/bin/nvim --clean --headless +"source ./minimal.lua" vim.schedule callback: ...omo/workspace/neovim/runtime/lua/vim/lsp/_capability.lua:209: scoped variable: Invalid buffer id: 2 stack traceback: [C]: in function '__index' ...omo/workspace/neovim/runtime/lua/vim/lsp/_capability.lua:209: in function 'is_enabled' ...e/notomo/workspace/neovim/runtime/lua/vim/lsp/client.lua:1108: in function <...e/notomo/workspace/neovim/runtime/lua/vim/lsp/client.lua:1101> ``` - reproduction minimal.lua ```lua vim.opt.runtimepath:append("/path/to/nvim-lspconfig/") vim.lsp.enable("lua_ls") vim.cmd.tabedit("runtime/lua/vim/_defaults.lua") vim.api.nvim_create_autocmd({ "LspAttach" }, { group = vim.api.nvim_create_augroup("test", {}), callback = function() vim.cmd.tabedit("runtime/lua/vim/_defaults.lua") local bufnr = vim.api.nvim_get_current_buf() vim.api.nvim_buf_delete(bufnr, { force = true }) end, }) ``` Solution: Check whether buffer is valid.
2025-08-31feat(lsp): support `textDocument/onTypeFormatting` (#34637)Riley Bruins1
Implements [on-type formatting](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification/#textDocument_onTypeFormatting) using a `vim.on_key()` approach to listen to typed keys. It will listen to keys on the *left hand side* of mappings. The `on_key` callback is cleared when detaching the last on-type formatting client. This feature is disabled by default. Co-authored-by: Maria José Solano <majosolano99@gmail.com>
2025-08-28refactor(lua): consistent use of local aliasesChristian Clason1
2025-08-25feat(lsp): support `textDocument/inlineCompletion`Yi Ming1
2025-08-18refactor(lsp): use `vim.lsp._capability.enable` internallyYi Ming1
2025-08-18refactor(lsp): no longer rely on `LspDetach` for detaching capabilitiesYi Ming1
2025-08-18refactor(lsp): move `util.enable` to `capability.enable`Yi Ming1