aboutsummaryrefslogtreecommitdiff
path: root/test/functional/plugin/lsp/completion_spec.lua
diff options
context:
space:
mode:
authorMathias Fußenegger <mfussenegger@users.noreply.github.com>2024-06-14 19:32:34 +0200
committerGitHub <noreply@github.com>2024-06-14 19:32:34 +0200
commitaa47af7e69bb32c4486510dce27f45d9028e0a6c (patch)
tree18313e0ad12ea97f4fc2ea6993bc0f935f110c51 /test/functional/plugin/lsp/completion_spec.lua
parentba70404c558169b813f51d5a0bb71cd540555c93 (diff)
downloadrneovim-aa47af7e69bb32c4486510dce27f45d9028e0a6c.tar.gz
rneovim-aa47af7e69bb32c4486510dce27f45d9028e0a6c.tar.bz2
rneovim-aa47af7e69bb32c4486510dce27f45d9028e0a6c.zip
fix(lsp): tune completion word extraction for decorated labels (#29331)
Problem: For snippets lsp.completion prefers the label if it is shorter than the insertText or textEdit to support postfix completion cases but clangd adds decoration characters to labels. E.g.: `•INT16_C(c)` Solution: Use parse_snippet on insertText/textEdit before checking if it is shorter than the label. Fixes https://github.com/neovim/neovim/issues/29301
Diffstat (limited to 'test/functional/plugin/lsp/completion_spec.lua')
-rw-r--r--test/functional/plugin/lsp/completion_spec.lua17
1 files changed, 16 insertions, 1 deletions
diff --git a/test/functional/plugin/lsp/completion_spec.lua b/test/functional/plugin/lsp/completion_spec.lua
index 0e81e4fddb..1b56d1740a 100644
--- a/test/functional/plugin/lsp/completion_spec.lua
+++ b/test/functional/plugin/lsp/completion_spec.lua
@@ -81,10 +81,21 @@ describe('vim.lsp.completion: item conversion', function()
-- plain text
{
label = 'foocar',
- sortText = 'k',
+ sortText = 'g',
insertText = 'foodar(${1:var1})',
insertTextFormat = 1,
},
+ {
+ label = '•INT16_C(c)',
+ insertText = 'INT16_C(${1:c})',
+ insertTextFormat = 2,
+ filterText = 'INT16_C',
+ sortText = 'h',
+ textEdit = {
+ newText = 'INT16_C(${1:c})',
+ range = range0,
+ },
+ },
}
local expected = {
{
@@ -115,6 +126,10 @@ describe('vim.lsp.completion: item conversion', function()
abbr = 'foocar',
word = 'foodar(${1:var1})', -- marked as PlainText, text is used as is
},
+ {
+ abbr = '•INT16_C(c)',
+ word = 'INT16_C',
+ },
}
local result = complete('|', completion_list)
result = vim.tbl_map(function(x)