aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/lsp/util.lua
diff options
context:
space:
mode:
authorMichael Lingelbach <m.j.lbach@gmail.com>2021-05-16 01:07:45 -0700
committerMichael Lingelbach <m.j.lbach@gmail.com>2021-05-16 15:25:34 -0700
commit63df353545f5d2e9b8d93f24d6f46b7852c43206 (patch)
tree4df96864996f322755e205e4f648849df24d73e2 /runtime/lua/vim/lsp/util.lua
parent21035cff9f1d279e3cb5ec866916bfa231cdbaa2 (diff)
downloadrneovim-63df353545f5d2e9b8d93f24d6f46b7852c43206.tar.gz
rneovim-63df353545f5d2e9b8d93f24d6f46b7852c43206.tar.bz2
rneovim-63df353545f5d2e9b8d93f24d6f46b7852c43206.zip
lsp: handle case where CompletionItem.insertTextFormat is nil
* Update tests to use explicit insertTextFormat for snippets
Diffstat (limited to 'runtime/lua/vim/lsp/util.lua')
-rw-r--r--runtime/lua/vim/lsp/util.lua6
1 files changed, 4 insertions, 2 deletions
diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua
index ce8468aa8a..287624f310 100644
--- a/runtime/lua/vim/lsp/util.lua
+++ b/runtime/lua/vim/lsp/util.lua
@@ -566,13 +566,15 @@ end
--@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_completion
local function get_completion_word(item)
if item.textEdit ~= nil and item.textEdit.newText ~= nil and item.textEdit.newText ~= "" then
- if protocol.InsertTextFormat[item.insertTextFormat] == "PlainText" then
+ local insert_text_format = protocol.InsertTextFormat[item.insertTextFormat]
+ if insert_text_format == "PlainText" or insert_text_format == nil then
return item.textEdit.newText
else
return M.parse_snippet(item.textEdit.newText)
end
elseif item.insertText ~= nil and item.insertText ~= "" then
- if protocol.InsertTextFormat[item.insertTextFormat] == "PlainText" then
+ local insert_text_format = protocol.InsertTextFormat[item.insertTextFormat]
+ if insert_text_format == "PlainText" or insert_text_format == nil then
return item.insertText
else
return M.parse_snippet(item.insertText)