Skip to content

Commit

Permalink
Merge pull request #106 from epheien/feat-kind
Browse files Browse the repository at this point in the history
feat: support string type kind
  • Loading branch information
hedyhli authored Dec 27, 2024
2 parents fca37f0 + ec0d2b7 commit be41835
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ External providers from plugins should define the provider module at

Each symbol table should have these fields:
- 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
`line` and `character`, each integers:
`{ start = { line = ?, character = ? }, ['end'] = { line = ?, character = ? } }`
Expand Down
10 changes: 10 additions & 0 deletions lua/outline/parser.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ local utils = require('outline.utils.init')

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,
-- simply reoganized by merging each property table from the arguments into a
-- table for each symbol)
Expand All @@ -20,6 +29,7 @@ local function parse_result(result, depth, hierarchy, parent, bufnr)

for index, value in pairs(result) do
-- 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
-- the hierarchy is basically a table of booleans which
-- tells whether the parent was the last in its group or
Expand Down

0 comments on commit be41835

Please sign in to comment.