aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/lsp/util.lua
diff options
context:
space:
mode:
authorMike Hartington <mhartington@users.noreply.github.com>2019-12-20 05:46:47 -0500
committerAshkan Kiani <ashkan.k.kiani@gmail.com>2019-12-20 02:46:47 -0800
commitd00c624ba4731ba7bfe9bd71e2cc32e54f886342 (patch)
treea65008bf3ecdfe40853fd33debfb0bced28c944b /runtime/lua/vim/lsp/util.lua
parent65aca4d857ab9ff278f410b17ef31d91e48a37b7 (diff)
downloadrneovim-d00c624ba4731ba7bfe9bd71e2cc32e54f886342.tar.gz
rneovim-d00c624ba4731ba7bfe9bd71e2cc32e54f886342.tar.bz2
rneovim-d00c624ba4731ba7bfe9bd71e2cc32e54f886342.zip
LSP: fix omnifunc findstart (#11522)
Diffstat (limited to 'runtime/lua/vim/lsp/util.lua')
-rw-r--r--runtime/lua/vim/lsp/util.lua25
1 files changed, 2 insertions, 23 deletions
diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua
index 3798b30a46..8f27353698 100644
--- a/runtime/lua/vim/lsp/util.lua
+++ b/runtime/lua/vim/lsp/util.lua
@@ -19,21 +19,6 @@ local function npcall(fn, ...)
return ok_or_nil(pcall(fn, ...))
end
---- Find the longest shared prefix between prefix and word.
--- e.g. remove_prefix("123tes", "testing") == "ting"
-local function remove_prefix(prefix, word)
- local max_prefix_length = math.min(#prefix, #word)
- local prefix_length = 0
- for i = 1, max_prefix_length do
- local current_line_suffix = prefix:sub(-i)
- local word_prefix = word:sub(1, i)
- if current_line_suffix == word_prefix then
- prefix_length = i
- end
- end
- return word:sub(prefix_length + 1)
-end
-
-- TODO(ashkan) @performance this could do less copying.
function M.set_lines(lines, A, B, new_lines)
-- 0-indexing to 1-indexing
@@ -161,15 +146,11 @@ end
--- Getting vim complete-items with incomplete flag.
-- @params CompletionItem[], CompletionList or nil (https://microsoft.github.io/language-server-protocol/specification#textDocument_completion)
-- @return { matches = complete-items table, incomplete = boolean }
-function M.text_document_completion_list_to_complete_items(result, line_prefix)
+function M.text_document_completion_list_to_complete_items(result)
local items = M.extract_completion_items(result)
if vim.tbl_isempty(items) then
return {}
end
- -- Only initialize if we have some items.
- if not line_prefix then
- line_prefix = M.get_current_line_to_cursor()
- end
local matches = {}
@@ -187,10 +168,8 @@ function M.text_document_completion_list_to_complete_items(result, line_prefix)
end
local word = completion_item.insertText or completion_item.label
-
- -- Ref: `:h complete-items`
table.insert(matches, {
- word = remove_prefix(line_prefix, word),
+ word = word,
abbr = completion_item.label,
kind = protocol.CompletionItemKind[completion_item.kind] or '',
menu = completion_item.detail or '',