aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/lsp/client.lua
Commit message (Collapse)AuthorAge
...
* refactor(lsp): unify capability checks and registration #36781Tristan Knight2025-12-06
| | | | | | | 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
* feat(lsp): `Client:stop()` defaults to `exit_timeout` #36783Olivia Kinnear2025-12-04
| | | | | | | | | 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.
* fix(lsp): default ClientConfig.exit_timeout to false #36811Olivia Kinnear2025-12-03
|
* fix(lsp): close timer when client exits (#36795)zeertzjq2025-12-03
| | | | | | | 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.
* feat(lsp): graduate ClientConfig `exit_timeout` #36750Olivia Kinnear2025-11-30
| | | | | | | | 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.
* feat(lsp): semanticTokens/range #36705Tristan Knight2025-11-30
| | | | | | | | | | | | 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.
* fix(lsp): don't immediately force shutdown when using a timeout (#36455)Maria Solano2025-11-05
|
* feat(lsp): support auto-force escalation in client stop (#36378)Maria Solano2025-11-01
|
* docs: types, news, lua-pluginJustin M. Keyes2025-10-24
| | | | | | - mention "lua_ls", not "luals". https://github.com/neovim/neovim/discussions/36182 Co-authored-by: Maria Solano <majosolano99@gmail.com>
* fix(lsp): replace `string` types with LSP method alias type annotations ↵David2025-10-16
| | | | | where appropriate. (#36180) fix(lsp): replace `string` types with LSP method alias where appropriate
* revert "fix(lsp): _get_workspace_folders does not handle root_dir() ↵Mathias Fußenegger2025-10-14
| | | | | | | function" #36183 This reverts commit 97ab24b9c7d9327740f0692f8076fed5737a52dc. See discussion in https://github.com/neovim/neovim/pull/36071
* fix(lsp): _get_workspace_folders does not handle root_dir() function #36071atusy2025-10-11
| | | | | | | | | | | | | | | | * 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>
* fix(lsp): typos in method names #36077Igor Lacerda2025-10-07
|
* fix(lsp): deprecate `vim.lsp.protocol.Methods` (#35998)Maria Solano2025-10-04
|
* fix(lsp): restore Client:stop() force-stopping behavior (#35800)zeertzjq2025-09-16
| | | | | | | | | | | | | 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!
* fix(lsp): avoid re-enabling `document_color` on `registerCapability` (#35774)skewb1k2025-09-15
| | | | | | | 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.
* fix(lsp): check if buffer is valid in scheduled client:on_attach() #35672notomo2025-09-08
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* feat(lsp): support `textDocument/onTypeFormatting` (#34637)Riley Bruins2025-08-31
| | | | | | | | | | 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>
* refactor(lua): consistent use of local aliasesChristian Clason2025-08-28
|
* feat(lsp): support `textDocument/inlineCompletion`Yi Ming2025-08-25
|
* refactor(lsp): use `vim.lsp._capability.enable` internallyYi Ming2025-08-18
|
* refactor(lsp): no longer rely on `LspDetach` for detaching capabilitiesYi Ming2025-08-18
|
* refactor(lsp): move `util.enable` to `capability.enable`Yi Ming2025-08-18
|
* refactor(lsp): check supported methods instead of `tbl_get`Yi Ming2025-08-17
|
* fix(lsp): deprecate vim.lsp.set_log_level, vim.lsp.get_log_path #35274Maria José Solano2025-08-11
|
* fix(lsp): decode 'null' in server responses as vim.NIL #34849skewb1k2025-08-03
| | | | | | | | | | | | | | | | Problem: Previously, 'null' value in LSP responses were decoded as 'nil'. This caused ambiguity for fields typed as '? | null' and led to loss of explicit 'null' values, particularly in 'data' parameters. Solution: Decode all JSON 'null' values as 'vim.NIL' and adjust handling where needed. This better aligns with the LSP specification, where 'null' and absent fields are distinct, and 'null' should not be used to represent missing values. This also enables proper validation of response messages to ensure that exactly one of 'result' or 'error' is present, as required by the JSON-RPC specification.
* refactor(lsp): inline `on_client_exit`Yi Ming2025-07-20
|
* refactor(lsp): track clients in `all_clients` once initializedYi Ming2025-07-20
|
* refactor(lsp): extract `Client._on_detach` to reduce duplicated codeYi Ming2025-07-20
|
* feat(lsp): support linked editing ranges #34388Riley Bruins2025-07-19
| | | ref: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_linkedEditingRange
* refactor(lsp): rename vim.lsp.semantic_tokens start/stop to enable()Yi Ming2025-07-13
|
* docs: api, pack, events, developJustin M. Keyes2025-07-10
|
* refactor(lsp): stateful data abstraction, vim.lsp.Capability #34639Yi Ming2025-07-07
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: Closes #31453 Solution: Introduce `vim.lsp.Capability`, which may serve as the base class for all LSP features that require caching data. it - was created if there is at least one client that supports the specific method; - was destroyed if all clients that support the method were detached. - Apply the refactor for `folding_range.lua` and `semantic_tokens.lua`. - Show active features in :checkhealth. Future: I found that these features that are expected to be refactored by `vim.lsp.Capability` have one characteristic in common: they all send LSP requests once the document is modified. The following code is different, but they are all for this purpose. - semantic tokens: https://github.com/neovim/neovim/blob/fb8dba413f2bcaa61c15d1854b28112e3e91a035/runtime/lua/vim/lsp/semantic_tokens.lua#L192-L198 - inlay hints, folding ranges, document color https://github.com/neovim/neovim/blob/fb8dba413f2bcaa61c15d1854b28112e3e91a035/runtime/lua/vim/lsp/inlay_hint.lua#L250-L266 I think I can sum up this characteristic as the need to keep certain data synchronized with the latest version computed by the server. I believe we can handle this at the `vim.lsp.Capability` level, and I think it will be very useful. Therefore, my next step is to implement LSP request sending and data synchronization on `vim.lsp.Capability`, rather than limiting it to the current create/destroy data approach.
* feat(lsp): pass resolved config to cmd() #34550Julian Visser2025-06-18
| | | | | | | | | | | | | | Problem: In LSP configs, the function form of `cmd()` cannot easily get the resolved root dir (workspace). One of the main use-cases of a dynamic `cmd()` is to be able to start a new server whose binary may be located *in the workspace* ([example](https://github.com/neovim/nvim-lspconfig/pull/3912)). Compare `reuse_client()`, which also receives the resolved config. Solution: Pass the resolved config to `cmd()`. Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
* docs: vim.fs., diagnostics, lsp #34402Justin M. Keyes2025-06-13
|
* feat(lsp): static registration support (#34371)Maria José Solano2025-06-09
|
* fix: type fixesLewis Russell2025-06-06
| | | | Type fixes caught by emmylua
* docs: news, intro, lsp, api #33687Justin M. Keyes2025-06-01
|
* fix(lsp): check if client is stopping before reuse #33796Eike2025-05-04
| | | | | | | Problem: Stopping a language server and then calling vim.lsp.start() with the same name/root will return the old language server that's in the middle of shutting down. vim.lsp.start() won't return a new server until the old process has terminated. Solution: Introducing a client._is_stopping field that tracks the shutdown phase, preventing the client from being reused.
* docs: lsp, lua #33682Justin M. Keyes2025-04-27
| | | | | | - sort fields alphabetically. - in the `vim.lsp.Client` docs, reference `vim.lsp.ClientConfig` instead of duplicating its docs. - cleanup lots of redundant-yet-drifted field docs.
* docs: lsp, emoji, startup #33446Justin M. Keyes2025-04-27
| | | Co-authored-by: Maria José Solano <majosolano99@gmail.com>
* fix(lsp): fallback to empty `capability_path` in `supports_registration`Maria José Solano2025-04-27
|
* fix(lsp): access correct client capability path in `supports_registration`Maria José Solano2025-04-26
|
* feat(lsp): generate method to client capability mapMaria José Solano2025-04-26
|
* fix(lsp): detect if Client:request resolved synchronously #33624Bartłomiej Maryńczak2025-04-26
| | | | | | | | | | | | | | | Problem: In cases when the (in-process) LSP server responds to the request immediately and calls `notify_reply_callback` the request will still be marked as pending, because the code assumes that the response will occur asynchronously. Then the request will be pending forever, because it was already set as "completed" before we even set it as "pending". A workaround is to wrap `notify_replay_callback` in `vim.shedule` ([like so](https://github.com/neovim/neovim/pull/24338#issuecomment-2809568617)] but that seems counterintuitive. Solution: Handle this case in Client:request().
* refactor(lsp): use method type annotations for parametersMaria José Solano2025-04-21
|
* feat(lsp): use stricter types for methodsLewis Russell2025-04-17
| | | | | | | | | | | | This change modifies gen_lsp.lua so alias types are generated for various types of lsp methods to distinguish between notifications and requests: - vim.lsp.protocol.Method.ServerToClient.Request - vim.lsp.protocol.Method.ServerToClient.Notification - vim.lsp.protocol.Method.ClientToServer.Request - vim.lsp.protocol.Method.ClientToServer.Notification These types are then used instead of `string` where appropriate.
* feat(lsp): workspace_required #31824Michael Strobel2025-03-30
| | | | | | | | | | Problem: Some language servers do not work properly without a workspace folder. Solution: Add `workspace_required`, which skips starting the lsp client if no workspace folder is found. Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
* docs: misc #31996Justin M. Keyes2025-03-02
|
* feat(lsp): use the meta model to generate server capability mapMaria José Solano2025-02-21
|