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

@@ -307,6 +307,7 @@ describe('vim.lsp.completion: item conversion', function()
info = '',
kind = 'Module',
menu = '',
hl_group = '',
word = 'this_thread',
}
local result = complete(' std::this|', completion_list)
@@ -362,6 +363,7 @@ describe('vim.lsp.completion: item conversion', function()
info = '',
kind = 'Module',
menu = '',
hl_group = '',
word = 'this_thread',
}
local result = complete(' std::this|is', completion_list)
@@ -529,6 +531,14 @@ describe('vim.lsp.completion: protocol', function()
{
label = 'hello',
},
{
label = 'hercules',
tags = { 1 }, -- 1 represents Deprecated tag
},
{
label = 'hero',
deprecated = true,
},
},
})
@@ -545,6 +555,7 @@ describe('vim.lsp.completion: protocol', function()
info = '',
kind = 'Unknown',
menu = '',
hl_group = '',
user_data = {
nvim = {
lsp = {
@@ -557,6 +568,50 @@ describe('vim.lsp.completion: protocol', function()
},
word = 'hello',
},
{
abbr = 'hercules',
dup = 1,
empty = 1,
icase = 1,
info = '',
kind = 'Unknown',
menu = '',
hl_group = 'DiagnosticDeprecated',
user_data = {
nvim = {
lsp = {
client_id = 1,
completion_item = {
label = 'hercules',
tags = { 1 },
},
},
},
},
word = 'hercules',
},
{
abbr = 'hero',
dup = 1,
empty = 1,
icase = 1,
info = '',
kind = 'Unknown',
menu = '',
hl_group = 'DiagnosticDeprecated',
user_data = {
nvim = {
lsp = {
client_id = 1,
completion_item = {
label = 'hero',
deprecated = true,
},
},
},
},
word = 'hero',
},
}, matches)
end)
end)