feat: cmp async (#1583)

This commit is contained in:
Folke Lemaitre
2023-05-25 19:46:53 +02:00
committed by GitHub
parent 950d0e3a93
commit abb5c7519d
9 changed files with 220 additions and 51 deletions

View File

@@ -376,7 +376,10 @@ entry.match = function(self, input, matching_config)
}
local score, matches, filter_text, _
local checked = {} ---@type string[]
filter_text = self:get_filter_text()
checked[filter_text] = true
score, matches = matcher.match(input, filter_text, option)
-- Support the language server that doesn't respect VSCode's behaviors.
@@ -390,16 +393,21 @@ entry.match = function(self, input, matching_config)
accept = accept or string.find(self:get_completion_item().textEdit.newText, prefix, 1, true)
if accept then
filter_text = prefix .. self:get_filter_text()
score, matches = matcher.match(input, filter_text, option)
if not checked[filter_text] then
checked[filter_text] = true
score, matches = matcher.match(input, filter_text, option)
end
end
end
end
end
local vim_item = self:get_vim_item(self:get_offset())
if filter_text ~= vim_item.abbr then
if score == 0 then
local vim_item = self:get_vim_item(self:get_offset())
filter_text = vim_item.abbr or vim_item.word
_, matches = matcher.match(input, filter_text, option)
if not checked[filter_text] then
_, matches = matcher.match(input, filter_text, option)
end
end
return { score = score, matches = matches }