Merge pull request #106 from epheien/feat-kind

feat: support string type kind
This commit is contained in:
~hedy
2024-12-27 09:04:40 +08:00
committed by GitHub
2 changed files with 11 additions and 1 deletions

View File

@@ -541,7 +541,7 @@ External providers from plugins should define the provider module at
Each symbol table should have these fields: Each symbol table should have these fields:
- name: string -- displayed in the outline - name: string -- displayed in the outline
- kind: integer -- determines the icon to use - kind: integer|string -- determines the icon to use
- selectionRange: table with fields `start` and `end`, each have fields - selectionRange: table with fields `start` and `end`, each have fields
`line` and `character`, each integers: `line` and `character`, each integers:
`{ start = { line = ?, character = ? }, ['end'] = { line = ?, character = ? } }` `{ start = { line = ?, character = ? }, ['end'] = { line = ?, character = ? } }`

View File

@@ -6,6 +6,15 @@ local utils = require('outline.utils.init')
local M = {} local M = {}
local function norm_kind(kind)
if type(kind) == 'number' then
return kind
else
-- string
return symbols.str_to_kind[kind] or 21 -- fallback to Null
end
end
---Parses result from LSP into a reorganized tree of symbols (not flattened, ---Parses result from LSP into a reorganized tree of symbols (not flattened,
-- simply reoganized by merging each property table from the arguments into a -- simply reoganized by merging each property table from the arguments into a
-- table for each symbol) -- table for each symbol)
@@ -20,6 +29,7 @@ local function parse_result(result, depth, hierarchy, parent, bufnr)
for index, value in pairs(result) do for index, value in pairs(result) do
-- FIXME: If a parent was excluded, all children will not be considered -- FIXME: If a parent was excluded, all children will not be considered
value.kind = norm_kind(value.kind)
if cfg.should_include_symbol(symbols.kinds[value.kind], bufnr) then if cfg.should_include_symbol(symbols.kinds[value.kind], bufnr) then
-- the hierarchy is basically a table of booleans which -- the hierarchy is basically a table of booleans which
-- tells whether the parent was the last in its group or -- tells whether the parent was the last in its group or