mirror of
https://github.com/neovim/neovim.git
synced 2024-12-19 18:55:14 -07:00
feat(lsp): include end_col
and end_lnum
in vim.lsp.buf.symbols_to_items
This commit is contained in:
parent
3f1d09bc94
commit
7c64dc833c
@ -223,7 +223,8 @@ LSP
|
|||||||
|
|
||||||
• Completion side effects (including snippet expansion, execution of commands
|
• Completion side effects (including snippet expansion, execution of commands
|
||||||
and application of additional text edits) is now built-in.
|
and application of additional text edits) is now built-in.
|
||||||
• |vim.lsp.util.locations_to_items()| sets `end_col` and `end_lnum` fields.
|
• |vim.lsp.util.locations_to_items()| and |vim.lsp.util.symbols_to_items()| now
|
||||||
|
sets `end_col` and `end_lnum` fields.
|
||||||
• |vim.lsp.buf.format()| now supports passing a list of ranges
|
• |vim.lsp.buf.format()| now supports passing a list of ranges
|
||||||
via the `range` parameter (this requires support for the
|
via the `range` parameter (this requires support for the
|
||||||
`textDocument/rangesFormatting` request).
|
`textDocument/rangesFormatting` request).
|
||||||
|
@ -1779,25 +1779,33 @@ function M.symbols_to_items(symbols, bufnr)
|
|||||||
bufnr = bufnr or 0
|
bufnr = bufnr or 0
|
||||||
local items = {} --- @type vim.quickfix.entry[]
|
local items = {} --- @type vim.quickfix.entry[]
|
||||||
for _, symbol in ipairs(symbols) do
|
for _, symbol in ipairs(symbols) do
|
||||||
--- @type string?, lsp.Position?
|
--- @type string?, lsp.Range?
|
||||||
local filename, pos
|
local filename, range
|
||||||
|
|
||||||
if symbol.location then
|
if symbol.location then
|
||||||
--- @cast symbol lsp.SymbolInformation
|
--- @cast symbol lsp.SymbolInformation
|
||||||
filename = vim.uri_to_fname(symbol.location.uri)
|
filename = vim.uri_to_fname(symbol.location.uri)
|
||||||
pos = symbol.location.range.start
|
range = symbol.location.range
|
||||||
elseif symbol.selectionRange then
|
elseif symbol.selectionRange then
|
||||||
--- @cast symbol lsp.DocumentSymbol
|
--- @cast symbol lsp.DocumentSymbol
|
||||||
filename = api.nvim_buf_get_name(bufnr)
|
filename = api.nvim_buf_get_name(bufnr)
|
||||||
pos = symbol.selectionRange.start
|
range = symbol.selectionRange
|
||||||
end
|
end
|
||||||
|
|
||||||
if filename and pos then
|
if filename and range then
|
||||||
local kind = protocol.SymbolKind[symbol.kind] or 'Unknown'
|
local kind = protocol.SymbolKind[symbol.kind] or 'Unknown'
|
||||||
|
|
||||||
|
local lnum = range['start'].line + 1
|
||||||
|
local col = range['start'].character + 1
|
||||||
|
local end_lnum = range['end'].line + 1
|
||||||
|
local end_col = range['end'].character + 1
|
||||||
|
|
||||||
items[#items + 1] = {
|
items[#items + 1] = {
|
||||||
filename = filename,
|
filename = filename,
|
||||||
lnum = pos.line + 1,
|
lnum = lnum,
|
||||||
col = pos.character + 1,
|
col = col,
|
||||||
|
end_lnum = end_lnum,
|
||||||
|
end_col = end_col,
|
||||||
kind = kind,
|
kind = kind,
|
||||||
text = '[' .. kind .. '] ' .. symbol.name,
|
text = '[' .. kind .. '] ' .. symbol.name,
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user