feat(lsp): lsp.completion support set deprecated (#29882)

Problem: CompletionItem in lsp spec mentioned the deprecated attribute

Solution: when item has deprecated attribute set hl_group to DiagnosticDeprecated
          in complete function
This commit is contained in:
glepnir
2024-07-31 22:15:34 +08:00
committed by GitHub
parent 573a71469d
commit 4e90bc3023
3 changed files with 74 additions and 1 deletions

View File

@@ -253,6 +253,13 @@ function M._lsp_to_complete_items(result, prefix, client_id)
for _, item in ipairs(items) do
if matches(item) then
local word = get_completion_word(item)
local hl_group = ''
if
item.deprecated
or vim.list_contains((item.tags or {}), protocol.CompletionTag.Deprecated)
then
hl_group = 'DiagnosticDeprecated'
end
table.insert(candidates, {
word = word,
abbr = item.label,
@@ -262,6 +269,7 @@ function M._lsp_to_complete_items(result, prefix, client_id)
icase = 1,
dup = 1,
empty = 1,
hl_group = hl_group,
user_data = {
nvim = {
lsp = {