aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/lsp/completion.lua
diff options
context:
space:
mode:
authorMathias Fussenegger <f.mathias@zignar.net>2025-02-21 18:37:05 +0100
committerMathias Fußenegger <mfussenegger@users.noreply.github.com>2025-02-22 09:33:54 +0100
commit8d7eb03040c26e8e3bdbf51b25fe03a735b85b5b (patch)
tree14b8d70d8b0b185838848f738e735e52eb4bc527 /runtime/lua/vim/lsp/completion.lua
parentdb2c3d1143fb5888602a2cee84578bd8a9c88bd7 (diff)
downloadrneovim-8d7eb03040c26e8e3bdbf51b25fe03a735b85b5b.tar.gz
rneovim-8d7eb03040c26e8e3bdbf51b25fe03a735b85b5b.tar.bz2
rneovim-8d7eb03040c26e8e3bdbf51b25fe03a735b85b5b.zip
fix(lsp): unify get_completion_word for textEdits/insertText
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`
Diffstat (limited to 'runtime/lua/vim/lsp/completion.lua')
-rw-r--r--runtime/lua/vim/lsp/completion.lua4
1 files changed, 1 insertions, 3 deletions
diff --git a/runtime/lua/vim/lsp/completion.lua b/runtime/lua/vim/lsp/completion.lua
index d99b1ffd0d..1466dcf438 100644
--- a/runtime/lua/vim/lsp/completion.lua
+++ b/runtime/lua/vim/lsp/completion.lua
@@ -132,7 +132,7 @@ end
--- @return string
local function get_completion_word(item, prefix, match)
if item.insertTextFormat == protocol.InsertTextFormat.Snippet then
- if item.textEdit then
+ if item.textEdit or (item.insertText and item.insertText ~= '') then
-- Use label instead of text if text has different starting characters.
-- label is used as abbr (=displayed), but word is used for filtering
-- This is required for things like postfix completion.
@@ -154,8 +154,6 @@ local function get_completion_word(item, prefix, match)
else
return word
end
- elseif item.insertText and item.insertText ~= '' then
- return parse_snippet(item.insertText)
else
return item.label
end