aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/lsp/util.lua
diff options
context:
space:
mode:
authorAndrey Avramenko <andreyavr@gmail.com>2020-03-06 19:40:46 +0200
committerAndrey Avramenko <andreyavr@gmail.com>2020-03-06 19:40:46 +0200
commitccb038dc6aaf72e052ef8afb810f84a331d4ccec (patch)
tree951ac74fd0439952f619c71516aaaaced16b0bc1 /runtime/lua/vim/lsp/util.lua
parentf8f41d088b2b7b503f638ce8930bedb32c0d32c5 (diff)
downloadrneovim-ccb038dc6aaf72e052ef8afb810f84a331d4ccec.tar.gz
rneovim-ccb038dc6aaf72e052ef8afb810f84a331d4ccec.tar.bz2
rneovim-ccb038dc6aaf72e052ef8afb810f84a331d4ccec.zip
LSP/completion: add textEdit support
According to lsp specification, value of insertText should be ignored if textEdit is provided.
Diffstat (limited to 'runtime/lua/vim/lsp/util.lua')
-rw-r--r--runtime/lua/vim/lsp/util.lua4
1 files changed, 2 insertions, 2 deletions
diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua
index 72c84b8471..533bcf2779 100644
--- a/runtime/lua/vim/lsp/util.lua
+++ b/runtime/lua/vim/lsp/util.lua
@@ -161,7 +161,7 @@ end
-- So we exclude completion candidates whose prefix does not match.
local function remove_unmatch_completion_items(items, prefix)
return vim.tbl_filter(function(item)
- local word = item.insertText or item.label
+ local word = (item.textEdit and item.textEdit.newText) or item.insertText or item.label
return vim.startswith(word, prefix)
end, items)
end
@@ -193,7 +193,7 @@ function M.text_document_completion_list_to_complete_items(result, prefix)
end
end
- local word = completion_item.insertText or completion_item.label
+ local word = (completion_item.textEdit and completion_item.textEdit.newText) or completion_item.insertText or completion_item.label
table.insert(matches, {
word = word,
abbr = completion_item.label,