aboutsummaryrefslogtreecommitdiff
path: root/test/functional/plugin/lsp_spec.lua
Commit message (Collapse)AuthorAge
...
* fix(lsp): reuse_win prioritizes windows/tabs currently displayed #36486Toby She2025-11-12
| | | | | | | | Problem: reuse_win will always jump to the first window containing the target buffer rather even if the buffer is displayed in the current window/tab Solution: check to see if the buffer is already displayed in the current window or any window of the current buffer
* 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): stop repeatedly resuming dead coroutine #35743tao2025-10-27
| | | | | | | | | | Problem: Error extracting content-length causes all future coroutine resumes to fail. Solution: Replace coroutine.wrap with coroutine.create in create_read_loop so that we can check its status and catch any errors, allowing us to stop the lsp client and avoid repeatedly resuming the dead coroutine.
* 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): "attempt to index nil config" #36189Justin M. Keyes2025-10-15
| | | | | | | | | | | | | | | | | Problem: If a client doesn't have a config then an error may be thrown. Probably caused by: 2f78ff816b03661b5f74d0624e973eaca0d64ef1 Lua callback: …/lsp.lua:442: attempt to index local 'config' (a nil value) stack traceback: …/lsp.lua:442: in function 'can_start' …/lsp.lua:479: in function 'lsp_enable_callback' …/lsp.lua:566: in function <…/lsp.lua:565> Solution: Not all clients necessarily have configs. - Handle `config=nil` in `can_start`. - If user "enables" an invalid name that happens to match a *client* name, don't auto-detach the client.
* 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>
* test(lsp): make async format test work properly (#35794)zeertzjq2025-09-17
| | | | | | | | | | | Overriding vim.lsp.handlers['textDocument/formatting'] doesn't work here because fake_lsp_server_setup() uses a table with __index to specify client handlers, which takes priority over vim.lsp.handlers[], and as a result the overridden handler is never called, and the test ends before the vim.wait() even finishes. Instead, set a global variable from the handler that is actually reached (by vim.rpcrequest() from client handler), and avoid stopping the event loop too early.
* fix(lsp): misleading logs in non-applicable filetypes #35749Justin M. Keyes2025-09-13
| | | | | | | | | | | | | | Problem: LSP logs show misleading "cannot start" messages when editing a filetype NOT listed in the `config.filetypes` field. [ERROR][2025-09-13 18:55:56] …/runtime//lua/vim/lsp/log.lua:151 "cannot start cssls due to config error: …/runtime//lua/vim/lsp.lua:423: cmd: expected expected function or table with executable command, got table: 0x0104701b18. Info: vscode-css-language-server is not executable" Solution: - `can_start`: check `config.filetypes` before checking the rest of the config.
* fix(lsp): don't treat MarkedString[] with language id as empty #35518Robert Muir2025-08-27
| | | | | | | | | Problem: Hover response of MarkedString[] where the first element contains a language identifier treated as empty. Solution: Fix empty check to handle case of MarkedString[] where the first element is a pair of a language and value.
* refactor(tests): remove redundant test #35364Justin M. Keyes2025-08-17
|
* fix(api,lsp): call on_detach before wiping out the buffer #35355Jaehwang Jung2025-08-17
| | | | | | | | | | Problem: Buffer-updates on_detach callback is invoked before buf_freeall(), which deletes autocmds of the buffer (via apply_autocmds(EVENT_BUFWIPEOUT, ...)). Due to this, buffer-local autocmds executed in on_detach (e.g., LspDetach) are not actually invoked. Solution: Call buf_updates_unload() before buf_freeall().
* feat(lsp): improve signature help display #35190skewb1k2025-08-06
| | | | | - Add delimiter between function signature and documentation, matching hover formatting - Show title only if there are multiple clients or multiple signatures - Avoid duplicating the title inside the window if it's already shown in the border
* 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.
* fix(lsp): support `containerName` in symbol requests #35029Riley Bruins2025-07-22
| | | The field is present for SymbolInformation and WorkspaceSymbol.
* fix(lsp): show notification with empty hover response (#35014)Maria José Solano2025-07-20
|
* feat(lsp): handle deprecated document symbols (#34751)Maria José Solano2025-07-06
|
* feat(lsp): support annotated text edits (#34508)Maria José Solano2025-06-23
|
* 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>
* feat(lsp): handle disabled code actions (#34453)Riley Bruins2025-06-16
| | | | This commit also makes it so that disabled code actions are not displayed unless the trigger kind is "Invoked".
* feat(lsp): workspace diagnostic support (#34262)Maria José Solano2025-06-09
| | | | | * refactor(lsp): remove underscore prefix from local variables * feat(lsp): workspace diagnostic support
* feat(lsp): static registration support (#34371)Maria José Solano2025-06-09
|
* docs: news, intro, lsp, api #33687Justin M. Keyes2025-06-01
|
* fix(lua): vim.validate `message` param #33675Justin M. Keyes2025-05-04
| | | | | | | Problem: vim.validate does not handle `message` param. Solution: Add the missing logic.
* 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.
* feat(lsp): detach LSP clients when 'filetype' changes #33707Jeremy Fleischman2025-05-03
| | | | | | | | | | | Problem: When the buffer 'filetype' changes, invalid or non-applicable LSP clients are not detached. https://github.com/neovim/neovim/issues/33443 https://github.com/neovim/nvim-lspconfig/issues/3326 Solution: In the enable() routine, check can_start() on _existing_ clients.
* feat(lsp): vim.lsp.is_enabled() #33703Jeremy Fleischman2025-05-03
| | | | | | | | | Problem: No way to check if a LSP config is enabled without causing it to resolve. E.g. `vim.lsp.config['…'] ~= nil` will resolve the config, which could be an unwanted and somewhat expensive side-effect. Solution: Introduce `vim.lsp.is_enabled()`.
* Merge pull request #28344 from bfredl/wonderlandbfredl2025-05-02
|\ | | | | feat(build): build.zig MVP: build and run functionaltests on linux
| * feat(build): build.zig MVP: build and run functionaltests on linuxbfredl2025-05-02
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | NEW BUILD SYSTEM! This is a MVP implementation which supports building the "nvim" binary, including cross-compilation for some targets. As an example, you can build a aarch64-macos binary from an x86-64-linux-gnu host, or vice versa Add CI target for build.zig currently for functionaltests on linux x86_64 only Follow up items: - praxis for version and dependency bumping - windows 💀 - full integration of libintl and gettext (or a desicion not to) - update help and API metadata files - installation into a $PREFIX - more tests and linters
* | feat(lsp): start/stop LSPs as necessary during vim.lsp.enable() #33702Jeremy Fleischman2025-04-30
| | | | | | | | | | | | | | | | | | | | Problem: enable() could be more flexible, so that it works even if called "late". Solution: - enable(true) calls `doautoall nvim.lsp.enable FileType`. - enable(false) calls `client:stop()` on matching clients. This will be useful for e.g. :LspStop/:LspStart also.
* | feat(lsp): `root_markers` can control priority #33485Lorenzo Bellina2025-04-30
|/ | | | | | | | | | | | | | | | | | Problem: root_markers cannot specify "equal priority filenames. Solution: Support nesting: { ... root_markers = { { ".stylua.toml", ".luarc.json" }, { ".git "} } ... } Co-authored-by: Maria José Solano <majosolano99@gmail.com> Co-authored-by: Gregory Anders <github@gpanders.com> Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
* test: drop redundant clear() #33654Justin M. Keyes2025-04-26
| | | followup to #33647 after overlapping merge
* test: drop redundant clear() #33647Justin M. Keyes2025-04-26
| | | | | | | | Problem: Tests call `clear()` even though `clear_notrace()` is already called in a `before_each()` handler, wasting precious milliseconds! Solution: Remove redundant `clear()` calls.
* 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().
* fix(lsp): opts.reuse_win does not jump if buf is already open #33476Au.2025-04-17
| | | | | | | | | | | | | | | | Problem: `vim.lsp.buf.[implementation|definition|...]({ reuse_win = true })` does not jump cursor to existing window if buffer is already open. Steps to reproduce: 1. `nvim repro.lua` 2. Insert anything that lsp can read to open the library definition/implementation, e.g., `vim.keymap.set` 3. open `repro.lua` buffer and the library buffer side by side. 4. type `gd` over `set` to jump to the library definition. The open buffer is scrolled to the target line, but cursor does not jump. Solution: Call nvim_set_current_win if necessary.
* fix(lsp): better handling of "*" configsLewis Russell2025-03-31
| | | | | | | | | | | | | | | Problem: If a config name contains "*" it causes rtp discovery of `lsp/` to consider the `*` as a wildcard and could lead to strange and unintended behaviour. For example, accessing the `'*'` config from a `lsp/` file would cause an infinite loop. Solution: - Explicitly disallow a config name from containing wildcards, with the exception of `'*'`. - When Resolving `'*'` config, skip the rtp step.
* 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>
* fix(lsp): handle using array as open_floating_preview title (#33016)Au.2025-03-22
|
* fix(lsp): handle non-existent configs in lsp.config/enableLewis Russell2025-03-12
|
* fix(lsp)!: pass buffer number to root_dir functionLewis Russell2025-03-10
| | | | | | | | | | | | | | Problem: The root dir function is not passed any context and can only assume the current buffer is the one being attached. The main use case is for getting the path of the buffer using `nvim_buf_get_name`. Solution: Pass the buffer number as the first argument.
* docs: OSC 133 shell config #32771Justin M. Keyes2025-03-07
|
* feat(lsp): support for resolving code action command (#32704)Maria José Solano2025-03-06
| | | | | * fix(lsp): don't call codeAction_resolve with commands * feat(lsp): support for resolving code action command
* fix(float): ensure floating window width can fit titleMaria José Solano2025-02-23
|
* feat(lsp)!: `symbol_to_item` requires `offset_encoding`Yi Ming2025-02-11
|
* 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.
* fix(lsp): minimum height for floating popup #31990Xuyuan Pang2025-01-13
| | | | | | | | | Problem: The floating window for hover and signature help always cuts off a few lines, because the `_make_floating_popup_size` function counts empty lines as having zero height. Solution: Ensure the height is at least 1.
* 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).
* 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()`.