mirror of
https://github.com/neovim/neovim.git
synced 2025-09-05 19:08:15 +00:00
fix(lsp): support containerName
in symbol requests #35029
The field is present for SymbolInformation and WorkspaceSymbol.
This commit is contained in:
@@ -2681,7 +2681,7 @@ symbols_to_items({symbols}, {bufnr}, {position_encoding})
|
|||||||
Converts symbols to quickfix list items.
|
Converts symbols to quickfix list items.
|
||||||
|
|
||||||
Parameters: ~
|
Parameters: ~
|
||||||
• {symbols} (`lsp.DocumentSymbol[]|lsp.SymbolInformation[]`)
|
• {symbols} (`lsp.DocumentSymbol[]|lsp.SymbolInformation[]|lsp.WorkspaceSymbol[]`)
|
||||||
list of symbols
|
list of symbols
|
||||||
• {bufnr} (`integer?`) buffer handle or 0 for current,
|
• {bufnr} (`integer?`) buffer handle or 0 for current,
|
||||||
defaults to current
|
defaults to current
|
||||||
|
@@ -1867,7 +1867,7 @@ end
|
|||||||
|
|
||||||
--- Converts symbols to quickfix list items.
|
--- Converts symbols to quickfix list items.
|
||||||
---
|
---
|
||||||
---@param symbols lsp.DocumentSymbol[]|lsp.SymbolInformation[] list of symbols
|
---@param symbols lsp.DocumentSymbol[]|lsp.SymbolInformation[]|lsp.WorkspaceSymbol[] list of symbols
|
||||||
---@param bufnr? integer buffer handle or 0 for current, defaults to current
|
---@param bufnr? integer buffer handle or 0 for current, defaults to current
|
||||||
---@param position_encoding? 'utf-8'|'utf-16'|'utf-32'
|
---@param position_encoding? 'utf-8'|'utf-16'|'utf-32'
|
||||||
--- default to first client of buffer
|
--- default to first client of buffer
|
||||||
@@ -1907,8 +1907,13 @@ function M.symbols_to_items(symbols, bufnr, position_encoding)
|
|||||||
|
|
||||||
local is_deprecated = symbol.deprecated
|
local is_deprecated = symbol.deprecated
|
||||||
or (symbol.tags and vim.tbl_contains(symbol.tags, protocol.SymbolTag.Deprecated))
|
or (symbol.tags and vim.tbl_contains(symbol.tags, protocol.SymbolTag.Deprecated))
|
||||||
local text =
|
local text = string.format(
|
||||||
string.format('[%s] %s%s', kind, symbol.name, is_deprecated and ' (deprecated)' or '')
|
'[%s] %s%s%s',
|
||||||
|
kind,
|
||||||
|
symbol.name,
|
||||||
|
symbol.containerName and ' in ' .. symbol.containerName or '',
|
||||||
|
is_deprecated and ' (deprecated)' or ''
|
||||||
|
)
|
||||||
|
|
||||||
items[#items + 1] = {
|
items[#items + 1] = {
|
||||||
filename = filename,
|
filename = filename,
|
||||||
|
@@ -3328,7 +3328,7 @@ describe('LSP', function()
|
|||||||
filename = '/test_a',
|
filename = '/test_a',
|
||||||
kind = 'File',
|
kind = 'File',
|
||||||
lnum = 2,
|
lnum = 2,
|
||||||
text = '[File] TestA',
|
text = '[File] TestA in TestAContainer',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
col = 1,
|
col = 1,
|
||||||
@@ -3337,7 +3337,7 @@ describe('LSP', function()
|
|||||||
filename = '/test_b',
|
filename = '/test_b',
|
||||||
kind = 'Module',
|
kind = 'Module',
|
||||||
lnum = 4,
|
lnum = 4,
|
||||||
text = '[Module] TestB',
|
text = '[Module] TestB in TestBContainer (deprecated)',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
eq(
|
eq(
|
||||||
@@ -3364,7 +3364,7 @@ describe('LSP', function()
|
|||||||
containerName = 'TestAContainer',
|
containerName = 'TestAContainer',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
deprecated = false,
|
deprecated = true,
|
||||||
kind = 2,
|
kind = 2,
|
||||||
name = 'TestB',
|
name = 'TestB',
|
||||||
location = {
|
location = {
|
||||||
|
Reference in New Issue
Block a user