forked from nvim-neo-tree/neo-tree.nvim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkinds.lua
67 lines (61 loc) · 1.74 KB
/
kinds.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
---Helper module to render symbols' kinds
---Need to be initialized by calling M.setup()
local M = {}
local kinds_id_to_name = {
[0] = "Root",
[1] = "File",
[2] = "Module",
[3] = "Namespace",
[4] = "Package",
[5] = "Class",
[6] = "Method",
[7] = "Property",
[8] = "Field",
[9] = "Constructor",
[10] = "Enum",
[11] = "Interface",
[12] = "Function",
[13] = "Variable",
[14] = "Constant",
[15] = "String",
[16] = "Number",
[17] = "Boolean",
[18] = "Array",
[19] = "Object",
[20] = "Key",
[21] = "Null",
[22] = "EnumMember",
[23] = "Struct",
[24] = "Event",
[25] = "Operator",
[26] = "TypeParameter",
}
local kinds_map = {}
---@class neotree.LspKindDisplay
---@field name string Display name
---@field icon string Icon to render
---@field hl string Highlight for the node
---Get how the kind with kind_id should be rendered
---@param kind_id integer the kind_id to be render
---@return neotree.LspKindDisplay res
M.get_kind = function(kind_id)
local kind_name = kinds_id_to_name[kind_id]
return vim.tbl_extend(
"force",
{ name = kind_name or ("Unknown: " .. kind_id), icon = "?", hl = "" },
kind_name and (kinds_map[kind_name] or {}) or kinds_map["Unknown"]
)
end
---Setup the module with custom kinds
---@param custom_kinds table additional kinds, should be of the form { [kind_id] = kind_name }
---@param kinds_display table mapping of kind_name to corresponding display name, icon and hl group
--- { [kind_name] = {
--- name = kind_display_name,
--- icon = kind_icon,
--- hl = kind_hl
--- }, }
M.setup = function(custom_kinds, kinds_display)
kinds_id_to_name = vim.tbl_deep_extend("force", kinds_id_to_name, custom_kinds or {})
kinds_map = kinds_display
end
return M