summaryrefslogtreecommitdiffstatshomepage
path: root/test/functional/plugin/lsp/completion_spec.lua
AgeCommit message (Collapse)AuthorFiles
2026-04-18fix(lsp): show CompletionItem.detail in info popup #38904glepnir1
Problem: completionItem/resolve response's `detail` field is silently dropped. Only `documentation` is shown in the popup. Solution: Prepend `detail` as a fenced code block before `documentation` in the info popup, skipping if documentation already contains it.
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-13feat(completion): completeopt=preselect, LSP CompletionItem.preselect #36613glepnir1
Problem: LSP CompletionItem.preselect is not supported. https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#completionClientCapabilities Solution: - Add "preselect" field to complete-items and "preselect" flag to 'completeopt'. - Set preselectSupport=true in LSP client capabilities.
2026-03-29fix(lsp): highlight snippet preview when server can't completionItem/resolve ↵Marcus Caisey1
(#38534) Problem: The snippet preview is not being highlighted by treesitter for completion items from servers which don't support `completionItem/resolve` (like gopls). This was broken by #38428. Solution: Call `update_popup_window` after updating the completion item with the snippet preview. I've added assertions to the `selecting an item triggers completionItem/resolve + (snippet) preview` test case which covers the snippet preview being shown since no tests failed when I removed the `nvim__complete_set` call which actually populates the preview on this codepath.
2026-03-23fix(lsp): completion word includes leading space from label #38435glepnir1
Problem: clangd prepends a space/bullet indicator to label. With labelDetailsSupport enabled, the signature moves to labelDetails, making label shorter. This flips the length comparison in get_completion_word, causing it to use item.label directly and insert the indicator into the buffer. Solution: only prefer filterText over label when label starts with non-keyword character in get_completion_word fallback branch.
2026-03-23fix(lsp): snippet preview blocked completionItem/resolve request #38428glepnir1
Problem: Generating snippet preview in get_doc() populated the documentation field before resolve, so the resolve request was never sent. Solution: Move snippet preview logic into on_completechanged and the resolve callback so it no longer blocks the resolve request.
2026-03-21feat(lsp): support CompletionItem.labelDetails #38403glepnir1
Problem: CompletionItem.labelDetails is ignored, losing function signatures and module info in the completion menu. Solution: Append labelDetails.detail to abbr and use labelDetails.description for menu with fallback to item.detail. https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#completionItemLabelDetails
2026-03-17fix(lsp): respect documentation markup kind in completion preview #38338glepnir1
Problem: Completion preview always assumes plain text, ignoring LSP documentation "kind". Solution: Pass markup kind from completion item to info window, or fallback to PlainText.
2026-03-14fix(lsp): handle non-string documentation in completion items #38291glepnir1
Problem: `get_doc` throws error with "attempt to get length of a userdata value" when `item.documentation` is truthy but not a string (e.g. vim.NIL from a JSON null). Solution: Check `type(item.documentation)` before taking its length.
2026-03-13fix(completion): wrong CompleteDone reason for auto-inserted sole match #38280glepnir1
Problem: #38169 used compl_used_match to determine the CompleteDone reason, but this fires too broadly, it also changes the reason to "accept" when the popup was shown and the user dismissed it with <Esc> or <Space>, breaking snippet completion with autocomplete. Solution: Instead of checking compl_used_match in, check whether the pum was never shown (compl_match_array == NULL) in ins_compl_stop(). When a match was inserted but the pum never displayed, set the completed word so CompleteDone fires with reason "accept". This keeps the "discard" reason intact when the user dismisses a visible pum without confirming.
2026-03-11fix(lsp): ensure augroup before querying autocmds #38254glepnir1
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-03-11feat(lsp): do completionItem/resolve if completeopt=popup #32820glepnir1
Problem: No completionItem/resolve handler. Solution: If completeopt=popup is set, invoke completionItem/resolve when a completion item is selected. Show resolved documentation in popup next to the completion menu.
2026-03-10feat(lsp): show snippet preview if completeopt=popup #32553glepnir1
Problem: LSP completion does not show snippet preview. Solution: Show snippet preview if 'completeopt' includes popup.
2026-02-28feat(lsp): show color preview in completion items #32138glepnir1
Problem: Color completion items display as plain text without visual preview Solution: Parse RGB/hex colors from documentation and render with colored symbol ■
2026-02-24refactor(test): lsp completion spec cleanup #38041glepnir1
Problem: retry/feed/tbl_map patterns duplicated everywhere, detach check was a false negative Solution: extract wait_for_pum/extract_word_abbr/word_sorter helpers, fix assert_cleanup_after_detach with positive+negative pum confirmation
2026-02-24refactor(test): avoid deprecated functions #37017glepnir1
Problem: Tests are using some deprecated functions. Solution: Replace with command, pcall_err, etc.
2026-02-22fix(lsp): vim.lsp.completion clean up triggers on client detach (#38009)glepnir1
Problem: LspDetach didn't clean up stale client refs in triggers table. Solution: create LspDetach autocmd and call disable_completion.
2026-02-18test(lsp): add entire-line completion word case (#37927)Bartłomiej Maryńczak1
Problem: Multiword completion items used to be cut at a first word. Solution: Add a test that ensures this does not regress in the future
2026-02-09fix(lsp): error on omnifunc completion (#37790)phanium1
Problem: After eaacdc9, complete with emmylua_ls error with: runtime/lua/vim/lsp/completion.lua:586: attempt to get length of field 'items' (a nil value) Solution: Result can be CompletionItem[] according the spec: > If a `CompletionItem[]` is provided, it is interpreted to be complete, > so it is the same as `{ isIncomplete: false, items }`
2026-02-08fix(lsp): ignore empty response on trigger completion #37663Tomasz N1
Problem: Empty response affects server start boundary computed before. Solution: Ignore empty responses. This is mostly micro-optimization that avoids extending existing results with empty responses.
2026-02-03fix(lsp): don't empty server start-boundary by next client response #37665Tomasz N1
Problem: Server start boundary can be emptied by response provided by next client. Solution: Don't empty it when extending the result list.
2026-01-30fix(lsp): use LSP textEdit range for completion start boundary (#37491)Harsh Kapse1
Previously, adjust_start_col returned nil when completion items had different start position from lsp textEdit range This caused the completion to fall back to \k*$ which ignores the non-keyword characters Changes: - adjust_start_col: now returns the minimum start postion among all items instead of nil - _lsp_to_complete_items - normalizes the items by adding the gap between current and minimum start Fixes: https://github.com/neovim/neovim/issues/37441
2025-12-16fix(lsp): sort items when completeopt include fuzzy #36974glepnir1
Problem: When fuzzy is enabled and the prefix is not empty, items are not sorted by fuzzy score before calling fn.complete. Solution: Use matchfuzzypos to get the scores and sort the items by fuzzy score before calling fn.complete.
2025-11-18fix(lsp): enable insertReplaceSupport for use in adjust_start_col #36569Jeff Martin1
Problem: With the typescript LSes typescript-language-server and vtsls, omnicompletion on partial tokens for certain types, such as array methods, and functions that are attached as attributes to other functions, either results in no entries populated in the completion menu (typescript-language-server), or an unfiltered completion menu with all array methods included, even if they don't share the same prefix as the partial token being completed (vtsls). Solution: Enable insertReplaceSupport and uses the insert portion of the lsp completion response in adjust_start_col if it's included in the response. Completion results are still filtered client side.
2025-11-18feat(lsp): user-specified sorting of lsp.completion multi-server results #36401glepnir1
Problem: No way to customize completion order across multiple servers. Solution: Add `cmp` function to `vim.lsp.completion.enable()` options for custom sorting logic.
2025-10-20fix(lsp): deduplicate completion items #36166Till Bungert1
The current implementation has a race condition where items are appended to the completion list twice when a second completion runs while the first is still going. This hotfix just deduplicates the entire list. Co-authored-by: Tomasz N <przepompownia@users.noreply.github.com>
2025-09-24test: don't call clear() in both before_each() and after_each() (#35901)zeertzjq1
2025-09-17fix(lsp): treat 2-triggers-at-once as "last char wins" #35435Tomasz N1
Problem: If there are 2 language servers with different trigger chars (`-` and `>`), and a keymap inputs both simultaneously (`->`), then `>` doesn't trigger. We get completion items from server1 only. This happens because the `completion_timer` for the `-` trigger is still pending. Solution: If the next character arrived enough quickly (< 25 ms), replace the existing deferred autotrigger with a new one that matches this later character.
2025-08-03fix(snippet): early return for final tabstop #35115TheBlob421
The cursor movement autocommand can not detect when the final tabstop $0 is directly adjacent to another tabstop, which prevents ending the snippet session. The fix is an early return when jumping.
2025-05-22fix(lsp): fix error with InsertReplaceEdit events #33973Evan Hahn1
Problem: Some LSPs cause the following completion error (reformatted slightly): Error executing vim.schedule lua callback: .../runtime/lua/vim/lsp/completion.lua:373 attempt to index field 'range' (a nil value) This is because an internal function assumes edits are either missing or of type `TextEdit`, but there's a third [possibility][0] that's not handled: the `InsertReplaceEdit`. This was previously reported in at least two issues: - https://github.com/neovim/neovim/issues/33142 - https://github.com/neovim/neovim/issues/33224 Solution: Don't assume the edit is a `TextEdit`. This implicitly handles `InsertReplaceEdit`s. Also, add a test case for this, which previously caused an error. [0]: https://github.com/neovim/neovim/blob/2c07428966a74c76003e00e2a37bf98eb8802c93/runtime/lua/vim/lsp/_meta/protocol.lua#L1099
2025-03-16refactor(lsp)!: rename lsp.completion.trigger() to get() (#32911)Mathias Fußenegger1
Problem: `trigger` is a custom word not yet used in APIs. Solution: Use `get` instead because the main effect is that the completion candidates will be collected (and shown by default, but follow-up commits are planned to add an `on_result` callback that allows more general handling). --------- Co-authored-by: Christian Clason <c.clason@uni-graz.at>
2025-03-14feat(snippet): set snippet keymaps permanent instead of dynamic (#31887)Mathias Fußenegger1
Problem: Given that `vim.snippet.expand()` sets temporary `<tab>`/`<s-tab>` keymaps there is no way to build "smart-tab" functionality where `<tab>` chooses the next completion candidate if the popup menu is visible. Solution: Set the keymap permanent in `_defaults`. The downside of this approach is that users of multiple snippet engine's need to adapt their keymaps to handle all their engines that are in use. For example: vim.keymap.set({ 'i', 's' }, "<Tab>", function() if foreign_snippet.active() then return "<Cmd>lua require('foreign_snippet').jump()<CR>" elseif vim.snippet.active({ direction = 1 }) then return "<Cmd>lua vim.snippet.jump(1)<CR>" else return key end end, { expr = true }) Upside is that using `vim.keymap.set` to override keymaps is a well established pattern and `vim.snippet.expand` calls made by nvim itself or plugins have working keymaps out of the box. Co-authored-by: Maria José Solano <majosolano99@gmail.com>
2025-03-10feat(lsp): support completion context #32793Maria José Solano1
Problem: vim.lsp.completion with "autotrigger" enabled, does not send completion context, even though it has all the necessary info. Solution: Include the context for "autotrigger". trigger() also optionally accepts context when manually invoked.
2025-02-22fix(lsp): unify get_completion_word for textEdits/insertTextMathias Fussenegger1
Problem: After https://github.com/neovim/neovim/pull/32377 selecting snippets provided by luals inserted the multi-line text before accepting the candidates. That's inconsistent with servers who provide `textEdit` instead of `insertText` and having lines shift up/down while cycling through the completion candidates is a bit irritating. Solution: Use the logic used for `textEdit` snippets also for `insertText`
2025-02-14feat(lsp): add support for completionItem.command resolvingMathias Fussenegger1
`command` was already resolved via a `completionItem/resolve` request but only if `additionalTextEdits` were also present, and the `resolveSupport` capability wasn't listed. Closes https://github.com/neovim/neovim/issues/32406
2025-02-13fix(lsp): clear word when expand multi-lines word (#32393)glepnir1
Problem: When expanding a completion item that contains a multi-line word, the word is not deleted correctly. Solution: If the word contains a line break, delete the text from Context.cursor to the current cursor position.
2025-02-13fix(lsp): autotrigger should only trigger on client's triggerCharacters (#32266)Robert Muir1
Problem: autotrigger option of vim.lsp.completion.enable() would trigger all clients, as long as it matched at least one client's triggerCharacters. Solution: trigger only the clients with triggerCharacters matching the character. overtriggering still happens if any client returns isIncomplete=true (this case is more involved). Co-authored-by: Mathias Fussenegger <f.mathias@zignar.net>
2025-01-19fix(lsp): don't use completion filterText if prefix is emptyMathias Fussenegger1
Follow up to https://github.com/neovim/neovim/pull/32072 If there is no prefix (e.g. at the start of word boundary or a line), it always used the `filterText` because the `match` function always returned false.
2025-01-17fix(lsp): use filterText as word if textEdit/label doesn't matchMathias Fussenegger1
Problem: With language servers like lemminx, completing xml tags like `<mo` first shows the right candidates (`modules`) but after typing `d` the candidates disappear. This is because the server returns: [...] filterText = "<module", label = "module", textEdit = { newText = "<module>$1</module>$0", Which resulted in `module` being used as `word`, and `module` doesn't match the prefix `<mo`. Typing `d` causes the `complete()` filtering mechanism to kick in and remove the entry. Solution: Use `<module` from the `filterText` as `word` if the textEdit/label heuristic doesn't match.
2024-12-13fix(lsp): reuse client if configs match and no root dirLewis Russell1
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
2024-11-13fix(lsp): filter completion candidates based on completeopt (#30945)Kristijan Husak1
2024-10-10fix(lsp): fix cursor position after snippet expansion (#30659)Tomasz N1
Problem: on `CompleteDone` cursor can jump to the end of line instead of the end of the completed word. Solution: remove only inserted word for snippet expansion instead of everything until eol. Fixes #30656 Co-authored-by: Mathias Fussenegger <f.mathias@zignar.net> Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
2024-10-10vim-patch:9.1.0771: completion attribute hl_group is confusingzeertzjq1
Problem: Currently completion attribute hl_group is combined with all items, which is redundant and confusing with kind_hlgroup Solution: Renamed to abbr_hlgroup and combine it only with the abbr item (glepnir). closes: vim/vim#15818 https://github.com/vim/vim/commit/0fe17f8ffbd2588ecd2bf42dced556897bc64f89 Co-authored-by: glepnir <glephunter@gmail.com>
2024-09-21test: support upvalues in exec_luaLewis Russell1
2024-09-01docs: misc #28970Justin M. Keyes1
2024-08-30fix(lsp): when prefix is non word add all result into matches (#30044)glepnir1
Problem: prefix can be a symbol like period, the fuzzy matching can't handle it correctly. Solution: when prefix is empty or a symbol add all lsp completion result into matches.
2024-08-22feat(lsp): completion opts support custom item conversion (#30060)glepnir1
Problem: Some items of completion results include function signatures that can cause the pum to be very long when a function has many params, because pum scales with the longest word/abbr. Solution: add custom covert function that can customise abbr to remove params.
2024-07-31feat(lsp): lsp.completion support set deprecated (#29882)glepnir1
Problem: CompletionItem in lsp spec mentioned the deprecated attribute Solution: when item has deprecated attribute set hl_group to DiagnosticDeprecated in complete function
2024-07-02fix(lsp): fallback to `label` for completion items if all others are missing ↵Sebastian Lyng Johansen1
(#29522)