diff options
author | Mathias Fußenegger <mfussenegger@users.noreply.github.com> | 2024-06-14 19:32:34 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-14 19:32:34 +0200 |
commit | aa47af7e69bb32c4486510dce27f45d9028e0a6c (patch) | |
tree | 18313e0ad12ea97f4fc2ea6993bc0f935f110c51 /runtime/lua/vim/lsp | |
parent | ba70404c558169b813f51d5a0bb71cd540555c93 (diff) | |
download | rneovim-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 'runtime/lua/vim/lsp')
-rw-r--r-- | runtime/lua/vim/lsp/completion.lua | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/runtime/lua/vim/lsp/completion.lua b/runtime/lua/vim/lsp/completion.lua index 4b7deabf41..2e6d82b367 100644 --- a/runtime/lua/vim/lsp/completion.lua +++ b/runtime/lua/vim/lsp/completion.lua @@ -145,8 +145,8 @@ local function get_completion_word(item) -- label: insert -- -- Typing `i` would remove the candidate because newText starts with `t`. - local text = item.insertText or item.textEdit.newText - return #text < #item.label and text or item.label + local text = parse_snippet(item.insertText or item.textEdit.newText) + return #text < #item.label and vim.fn.matchstr(text, '\\k*') or item.label elseif item.insertText and item.insertText ~= '' then return parse_snippet(item.insertText) else |