feat(parser): Support SymbolInformation[]

-- https://microsoft.github.io/language-server-protocol/specification#textDocument_documentSymbol
Some lsp like vuels, pyls etc dont support the newer DocumentSymbol[]
data structure so add minimal support for the old way. This is not
hierarchical so not really a tree

Addresses #13
This commit is contained in:
simrat39
2021-05-03 16:02:56 -07:00
parent 6cffe24f33
commit c9c68de360

View File

@@ -33,16 +33,28 @@ function M.parse(result, depth, heirarchy)
children = M.parse(value.children, level + 1, child_hir)
end
-- support SymbolInformation[]
-- https://microsoft.github.io/language-server-protocol/specification#textDocument_documentSymbol
local selectionRange = value.selectionRange
if value.selectionRange == nil then
selectionRange = value.location.range
end
local range = value.range
if value.range == nil then
range = value.location.range
end
table.insert(ret, {
deprecated = value.deprecated,
kind = value.kind,
icon = symbols.icon_from_kind(value.kind),
name = value.name,
detail = value.detail,
line = value.selectionRange.start.line,
range_start = value.range.start.line,
range_end = value.range["end"].line,
character = value.selectionRange.start.character,
line = selectionRange.start.line,
character = selectionRange.start.character,
range_start = range.start.line,
range_end = range["end"].line,
children = children,
depth = level,
isLast = isLast,