aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/lsp.lua
Commit message (Collapse)AuthorAge
* docs: miscdundargoc2025-01-30
| | | | | | | | | Co-authored-by: Dustin S. <dstackmasta27@gmail.com> Co-authored-by: Ferenc Fejes <fejes@inf.elte.hu> Co-authored-by: Maria José Solano <majosolano99@gmail.com> Co-authored-by: Yochem van Rosmalen <git@yochem.nl> Co-authored-by: brianhuster <phambinhanctb2004@gmail.com> Co-authored-by: zeertzjq <zeertzjq@outlook.com>
* Merge #32001 from MariaSolOs/consistent-namespacesJustin M. Keyes2025-01-15
|\
| * refactor: use nvim.foo.bar format for autocommand groupsMaria José Solano2025-01-14
| |
* | fix(lsp): vim.lsp.enable(...,false) does not disable #32002Andrew Braxton2025-01-15
| | | | | | | | | | | | | | | | | | | | | | | | Problem: Per the documentation, passing `false` as the `enable` parameter of `vim.lsp.enable()` should disable the given LSP(s), but it does not work due to a logic error. Specifically, `enable == false and nil or {}` will always evaluate to `{}` because `nil` is falsy. Solution: Correct the conditional statement.
* | fix(lsp): schedule call to vim.lsp.start for async root_dir (#31998)Gregory Anders2025-01-14
|/ | | | | | When `root_dir` is a function it can (and often will) call the provided callback function in a fast API context (e.g. in the `on_exit` handler of `vim.system`). When the callback function is executed we should ensure that it runs vim.lsp.start on the main event loop.
* docs: miscdundargoc2025-01-11
| | | | | | | | | | | | | | | Co-authored-by: Axel <axelhjq@gmail.com> Co-authored-by: Colin Kennedy <colinvfx@gmail.com> Co-authored-by: Daiki Noda <sys9kdr@users.noreply.github.com> Co-authored-by: Evgeni Chasnovski <evgeni.chasnovski@gmail.com> Co-authored-by: Jean-Jacq du Plessis <1030058+jj-du-plessis@users.noreply.github.com> Co-authored-by: Juan Giordana <juangiordana@gmail.com> Co-authored-by: Lincoln Wallace <locnnil0@gmail.com> Co-authored-by: Matti Hellström <hellstrom@scm.com> Co-authored-by: Steven Locorotondo <steven.locorotondo@justeattakeaway.com> Co-authored-by: Yochem van Rosmalen <git@yochem.nl> Co-authored-by: glepnir <glephunter@gmail.com> Co-authored-by: ifish <fishioon@live.com>
* feat(lsp): return resolved config for vim.lsp.config[name]Mathias Fussenegger2024-12-31
| | | | | | | | | | Allows to retrieve the configuration as it will be used by `lsp.enable` - including the parts merged from `*` and rtp. This is useful for explicit startup control (`vim.lsp.start(vim.lsp.config[name])`) Closes https://github.com/neovim/neovim/issues/31640
* feat(lsp): support function for client root_dir (#31630)Gregory Anders2024-12-27
| | | | | | | | If root_dir is a function it is evaluated when the client is created to determine the root directory. This enables dynamically determining the root directory based on e.g. project or directory structure (example: finding a parent Cargo.toml file that contains "[workspace]" in a Rust project).
* feat(lsp): return table from lsp/ files on runtimepath (#31663)Gregory Anders2024-12-21
| | | | | | | | Problem: LSP configs on the runtimepath must have the same name as the LSP server and must also explicitly set the name in vim.lsp.config. This is redundant and creates a footgun where a user may accidentally use the wrong name when assigning to the vim.lsp.config table. Solution: Return a table from lsp/ runtimepath files instead
* fix(lsp): vim.lsp.start fails if existing client has no workspace_folders #31608phanium2024-12-18
| | | | | | | | | | | | | | | | | | | | | | | | | Problem: regression since https://github.com/neovim/neovim/pull/31340 `nvim -l repro.lua`: ```lua vim.lsp.start { cmd = { 'lua-language-server' }, name = 'lua_ls' } vim.lsp.start { cmd = { 'lua-language-server' }, name = 'lua_ls', root_dir = 'foo' } -- swapped case will be ok: -- vim.lsp.start { cmd = { 'lua-language-server' }, name = 'lua_ls', root_dir = 'foo' } -- vim.lsp.start { cmd = { 'lua-language-server' }, name = 'lua_ls' } ``` Failure: ``` E5113: Error while calling lua chunk: /…/lua/vim/lsp.lua:214: bad argument #1 to 'ipairs' (table expected, got nil) stack traceback: [C]: in function 'ipairs' /…/lua/vim/lsp.lua:214: in function 'reuse_client' /…/lua/vim/lsp.lua:629: in function 'start' repro.lua:34: in main chunk ```
* fix(lsp): reuse client if configs match and no root dirLewis Russell2024-12-13
| | | | | | | | | | | | Problem: An LSP configuration that creates client with no root_dir or workspace_folders can result in vim.lsp.enable attaching to it multiple times. Solution: When checking existing clients, reuse a client if it wasn't initially configured have any workspace_folders. This more closely matches the behaviour we had prior to d9235ef
* feat(lsp): add vim.lsp.config and vim.lsp.enableLewis Russell2024-12-10
| | | | | | | | | | | | | | | | | | | | Design goals/requirements: - Default configuration of a server can be distributed across multiple sources. - And via RTP discovery. - Default configuration can be specified for all servers. - Configuration _can_ be project specific. Solution: - Two new API's: - `vim.lsp.config(name, cfg)`: - Used to define default configurations for servers of name. - Can be used like a table or called as a function. - Use `vim.lsp.confg('*', cfg)` to specify default config for all servers. - `vim.lsp.enable(name)` - Used to enable servers of name. Uses configuration defined via `vim.lsp.config()`.
* refactor: add vim._resolve_bufnrLewis Russell2024-12-07
|
* fix: remove vim.lsp._with_extendLewis Russell2024-12-07
| | | | Not used anywhere.
* fix(lsp): check for configuration workspace folders when reusing clientsMaria José Solano2024-12-07
|
* 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
* docs: provide example for configuring LSP foldexpr (#31411)Gregory Anders2024-12-02
| | | | | Using the "supports_method" function with a client capability inside of an LspAttach autocommand is the preferred method to do this, so we should be showing users how to do it.
* feat(lsp): support `textDocument/foldingRange` (#31311)Yi Ming2024-11-29
| | | | | | | | | | | | | | | | | | | * refactor(shared): extract `vim._list_insert` and `vim._list_remove` * feat(lsp): add `vim.lsp.foldexpr()` * docs(lsp): add a todo for state management * feat(lsp): add `vim.lsp.folding_range.foldclose()` * feat(lsp): schedule `foldclose()` if the buffer is not up-to-date * feat(lsp): add `vim.lsp.foldtext()` * feat(lsp): support multiple folding range providers * refactor(lsp): expose all folding related functions under `vim.lsp.*` * perf(lsp): add `lsp.MultiHandler` for do `foldupdate()` only once
* fix(lsp): hover keymap (#31208)andrew snelling2024-11-22
| | | | | * fix: use function call in keymap * fix: test
* feat(lsp): deprecate non-method client functionsLewis Russell2024-11-20
| | | | | | | | | | | | | | Deprecated: - `client.request()` -> `client:request()` - `client.request_sync()` -> `client:request_sync()` - `client.notify()` -> `client:notify()` - `client.cancel_request()` -> `client:cancel_request()` - `client.stop()` -> `client:stop()` - `client.is_stopped()` `client:is_stopped()` - `client.supports_method()` -> `client:supports_method()` - `client.on_attach()` -> `client:on_attach()` Fixed docgen to link class fields to the full function doc.
* refactor(lsp): fold in dynamic_registration code into the clientLewis Russell2024-11-18
| | | | | | | | | | | Problem: Capability register logic is spread across 3 files. Solution: - Consolidate (and simplify) logic into the client. - Teach client.supports_method about resolve methods
* 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).
* Merge pull request #30935 from lewis6991/feat/lsp_multi_hoverLewis Russell2024-10-29
|\
| * feat(lsp)!: multiple client support for vim.lsp.buf.hover()Lewis Russell2024-10-29
| | | | | | | | Deprecate `vim.lsp.handlers.hover` and `vim.lsp.handlers['textDocument/hover']`
| * refactor(lsp): buf_request_allLewis Russell2024-10-29
| |
* | fix(lsp): compare URI instead of workspace folder name (#30962)Gregory Anders2024-10-27
| | | | | | | | | | | | The workspace folder name is meant to be a human-readable name which is only used in the UI. Comparing the name against root_dir is thus not a valid comparison. Instead, we should compare the workspace folder's URI against the root dir URI.
* | 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)
* fix(lsp.buf): use correct offset_encoding for all requestsLewis Russell2024-10-24
| | | | | | | | | | | | | | | Problem: `lsp.buf_request` send the same params to all servers and many calls to this pass PositionalParams which depends on the clients offset_encoding. This can result with incorrect params being sent to a server. Solution: `lsp.buf_request` `params` argument can now be passed as a function which takes the client as the first argument. This is used in lsp/buf.lua to construct correct params for each client request.
* docs: miscdundargoc2024-10-23
| | | | | | | Co-authored-by: David Pedersen <limero@me.com> Co-authored-by: Gregory Anders <greg@gpanders.com> Co-authored-by: Leo Schlosser <Leo.Schlosser@Student.HTW-Berlin.de> Co-authored-by: zeertzjq <zeertzjq@outlook.com>
* 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.
* docs: misc (#29719)dundargoc2024-08-29
| | | | | | | | | Co-authored-by: Evgeni Chasnovski <evgeni.chasnovski@gmail.com> Co-authored-by: Lauri Heiskanen <lauri.heiskanen@nimble.fi> Co-authored-by: Piotr Doroszewski <5605596+Doroszewski@users.noreply.github.com> Co-authored-by: Tobiasz Laskowski <tobil4sk@outlook.com> Co-authored-by: ariel-lindemann <41641978+ariel-lindemann@users.noreply.github.com> Co-authored-by: glepnir <glephunter@gmail.com> Co-authored-by: zeertzjq <zeertzjq@outlook.com>
* fix(lsp): update request name to capability map #30098atusy2024-08-20
| | | | | | | | | | Add items based on specifications (<https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocumentClientCapabilities>) - textDocument/documentColor - textDocument/inlineValue - textDocument/linkedEditingRange - textDocument/moniker - textDocument/onTypeFormatting - textDocument/selectionRange
* fix(lsp): don't show codelens for buffers that don't support it (#29690)Riley Bruins2024-07-16
|
* refactor: use `vim._with` where possibledundargoc2024-06-28
| | | | | This mostly means replacing `nvim_buf_call` and `nvim_win_call` with `vim._with`.
* fix(lsp): avoid vim.keymap.del error when stopping a client (#29478)Matt Fellenz2024-06-26
|
* feat(lsp): vim.lsp.buf.format() supports textDocument/rangesFormatting #27323Tom Praschan2024-06-24
| | | | | | | | | | While this relies on a proposed LSP 3.18 feature, it's fully backwards compatible, so IMO there's no harm in adding this already. Looks like some servers already support for this e.g. - gopls: https://go-review.googlesource.com/c/tools/+/510235 - clangd: https://github.com/llvm/llvm-project/pull/80180 Fixes #27293
* fix(lsp): do not reset buf version when detaching client (#29242)Ilia Choly2024-06-10
|
* fix(lsp): revert buf_versions deprecation/replacement (#29217)Mathias Fußenegger2024-06-07
| | | | | | | | | * Revert "fix(lsp): account for changedtick version gap on modified reset (#29170)" This reverts commit 2e6d295f799c27372e5c0c44727fa613c81717fd. * Revert "refactor(lsp): replace util.buf_versions with changedtick (#28943)" This reverts commit 5c33815448e11b514678f39cecc74e68131d4628.
* 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(lsp): check if buffer is valid before LspDetach autocmd (#29162)Saltaformajo2024-06-04
|
* refactor(lsp): replace util.buf_versions with changedtick (#28943)Mathias Fußenegger2024-05-30
| | | | | | | `lsp.util.buf_versions` was already derived from changedtick (`on_lines` from `buf_attach` synced the version) As far as I can tell there is no need to keep track of the state in a separate table.
* fix(lsp): clear lsp client diagnostics (#29050)crwebb852024-05-30
| | | | | | | Problem: When an lsp client is stopped, the client will only clear the diagnostics for the attached buffers but not the unattached buffers. Solution: Reset the diagnostics for the whole namespace rather than for only the attached buffers.
* Merge pull request #27339 from MariaSolOs/completionGregory Anders2024-05-28
|\ | | | | feat(lsp): completion side effects
| * feat(lsp): completion side effectsMaria José Solano2024-05-27
| |
* | fix(lsp): do not detach from buffer if there are uninitialized clients (#29029)Ilia Choly2024-05-27
|/ | | | | Problem: if on_lines is called before the LSP is initialized, the buffer is detached. Solution: check for uninitialized clients before detaching.
* refactor(lsp): reuse buf_detach_client logic in on_detach (#28939)Mathias Fußenegger2024-05-23
|
* fix(lsp): trigger LspDetach on buffer delete (#28795)Andre Toerien2024-05-23
| | | Co-authored-by: Mathias Fussenegger <f.mathias@zignar.net>
* refactor(lsp): use supports_method where applicableIlia Choly2024-05-22
|
* fix(lsp): detach all clients on_reload to force buf_state reload (#28875)Ilia Choly2024-05-21
| | | | | | Problem: The changetracking state can de-sync when reloading a buffer with more than one LSP client attached. Solution: Fully detach all clients from the buffer to force buf_state to be re-created.
* fix(lsp): add textDocument/documentLink to capability map (#28838)Ilia Choly2024-05-21
|