mirror of
https://github.com/neovim/neovim.git
synced 2025-12-07 23:22:39 +00:00
lsp: Handle unknown CompletionItemKind and SymbolKind (#12257)
* lsp: handle kinds not specified in protocol fix: #12200 If the client set "symbolKind.valueSet", the client must handle it properly even if it receives a value outside the specification. * test: add lsp.util.{get_completion_item_kind_name, get_symbol_kind_name} test case * lsp: make lsp.util.{get_completion_item_kind_name, get_symbol_kind_name} private
This commit is contained in:
@@ -934,12 +934,12 @@ describe('LSP', function()
|
||||
}
|
||||
local completion_list_items = {items=completion_list}
|
||||
local expected = {
|
||||
{ abbr = 'foobar', dup = 1, empty = 1, icase = 1, info = ' ', kind = '', menu = '', word = 'foobar', user_data = { nvim = { lsp = { completion_item = { label = 'foobar' } } } } },
|
||||
{ abbr = 'foobar', dup = 1, empty = 1, icase = 1, info = ' ', kind = '', menu = '', word = 'foobar', user_data = { nvim = { lsp = { completion_item = { label='foobar', textEdit={} } } } } },
|
||||
{ abbr = 'foocar', dup = 1, empty = 1, icase = 1, info = ' ', kind = '', menu = '', word = 'foobar', user_data = { nvim = { lsp = { completion_item = { label='foocar', insertText='foobar' } } } } },
|
||||
{ abbr = 'foocar', dup = 1, empty = 1, icase = 1, info = ' ', kind = '', menu = '', word = 'foobar', user_data = { nvim = { lsp = { completion_item = { label='foocar', insertText='foobar', textEdit={} } } } } },
|
||||
{ abbr = 'foocar', dup = 1, empty = 1, icase = 1, info = ' ', kind = '', menu = '', word = 'foobar', user_data = { nvim = { lsp = { completion_item = { label='foocar', insertText='foodar', textEdit={newText='foobar'} } } } } },
|
||||
{ abbr = 'foocar', dup = 1, empty = 1, icase = 1, info = ' ', kind = '', menu = '', word = 'foobar', user_data = { nvim = { lsp = { completion_item = { label='foocar', textEdit={newText='foobar'} } } } } },
|
||||
{ abbr = 'foobar', dup = 1, empty = 1, icase = 1, info = ' ', kind = 'Unknown', menu = '', word = 'foobar', user_data = { nvim = { lsp = { completion_item = { label = 'foobar' } } } } },
|
||||
{ abbr = 'foobar', dup = 1, empty = 1, icase = 1, info = ' ', kind = 'Unknown', menu = '', word = 'foobar', user_data = { nvim = { lsp = { completion_item = { label='foobar', textEdit={} } } } } },
|
||||
{ abbr = 'foocar', dup = 1, empty = 1, icase = 1, info = ' ', kind = 'Unknown', menu = '', word = 'foobar', user_data = { nvim = { lsp = { completion_item = { label='foocar', insertText='foobar' } } } } },
|
||||
{ abbr = 'foocar', dup = 1, empty = 1, icase = 1, info = ' ', kind = 'Unknown', menu = '', word = 'foobar', user_data = { nvim = { lsp = { completion_item = { label='foocar', insertText='foobar', textEdit={} } } } } },
|
||||
{ abbr = 'foocar', dup = 1, empty = 1, icase = 1, info = ' ', kind = 'Unknown', menu = '', word = 'foobar', user_data = { nvim = { lsp = { completion_item = { label='foocar', insertText='foodar', textEdit={newText='foobar'} } } } } },
|
||||
{ abbr = 'foocar', dup = 1, empty = 1, icase = 1, info = ' ', kind = 'Unknown', menu = '', word = 'foobar', user_data = { nvim = { lsp = { completion_item = { label='foocar', textEdit={newText='foobar'} } } } } },
|
||||
}
|
||||
|
||||
eq(expected, exec_lua([[return vim.lsp.util.text_document_completion_list_to_complete_items(...)]], completion_list, prefix))
|
||||
@@ -1239,4 +1239,28 @@ describe('LSP', function()
|
||||
]])
|
||||
end)
|
||||
end)
|
||||
|
||||
describe('lsp.util._get_completion_item_kind_name', function()
|
||||
describe('returns the name specified by protocol', function()
|
||||
eq("Text", exec_lua("return vim.lsp.util._get_completion_item_kind_name(1)"))
|
||||
eq("TypeParameter", exec_lua("return vim.lsp.util._get_completion_item_kind_name(25)"))
|
||||
end)
|
||||
describe('returns the name not specified by protocol', function()
|
||||
eq("Unknown", exec_lua("return vim.lsp.util._get_completion_item_kind_name(nil)"))
|
||||
eq("Unknown", exec_lua("return vim.lsp.util._get_completion_item_kind_name(vim.NIL)"))
|
||||
eq("Unknown", exec_lua("return vim.lsp.util._get_completion_item_kind_name(1000)"))
|
||||
end)
|
||||
end)
|
||||
|
||||
describe('lsp.util._get_symbol_kind_name', function()
|
||||
describe('returns the name specified by protocol', function()
|
||||
eq("File", exec_lua("return vim.lsp.util._get_symbol_kind_name(1)"))
|
||||
eq("TypeParameter", exec_lua("return vim.lsp.util._get_symbol_kind_name(26)"))
|
||||
end)
|
||||
describe('returns the name not specified by protocol', function()
|
||||
eq("Unknown", exec_lua("return vim.lsp.util._get_symbol_kind_name(nil)"))
|
||||
eq("Unknown", exec_lua("return vim.lsp.util._get_symbol_kind_name(vim.NIL)"))
|
||||
eq("Unknown", exec_lua("return vim.lsp.util._get_symbol_kind_name(1000)"))
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user