-
Notifications
You must be signed in to change notification settings - Fork 35
/
init.lua
106 lines (97 loc) · 2.41 KB
/
init.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
local lspkind = {}
local fmt = string.format
local kind_presets = {
default = {
-- if you change or add symbol here
-- replace corresponding line in readme
Text = "",
Method = "",
Function = "",
Constructor = "",
Field = "ﰠ",
Variable = "",
Class = "ﴯ",
Interface = "",
Module = "",
Property = "ﰠ",
Unit = "塞",
Value = "",
Enum = "",
Keyword = "",
Snippet = "",
Color = "",
File = "",
Reference = "",
Folder = "",
EnumMember = "",
Constant = "",
Struct = "פּ",
Event = "",
Operator = "",
TypeParameter = ""
},
codicons = {
Text = "",
Method = "",
Function = "",
Constructor = "",
Field = "",
Variable = "",
Class = "",
Interface = "",
Module = "",
Property = "",
Unit = "",
Value = "",
Enum = "",
Keyword = "",
Snippet = "",
Color = "",
File = "",
Reference = "",
Folder = "",
EnumMember = "",
Constant = "",
Struct = "",
Event = "",
Operator = "",
TypeParameter = "",
},
}
local kind_order = {
'Text', 'Method', 'Function', 'Constructor', 'Field', 'Variable', 'Class', 'Interface', 'Module',
'Property', 'Unit', 'Value', 'Enum', 'Keyword', 'Snippet', 'Color', 'File', 'Reference', 'Folder',
'EnumMember', 'Constant', 'Struct', 'Event', 'Operator', 'TypeParameter'
}
function lspkind.init(opts)
local with_text = opts == nil or opts['with_text']
local preset
if opts == nil or opts['preset'] == nil then
preset = 'default'
else
preset = opts['preset']
end
local symbol_map = kind_presets[preset]
local symbol_map = (opts and opts['symbol_map'] and
vim.tbl_extend('force', symbol_map, opts['symbol_map'])) or symbol_map
local symbols = {}
local len = 25
if with_text == true or with_text == nil then
for i = 1, len do
local name = kind_order[i]
local symbol = symbol_map[name]
symbol = symbol and (symbol .. ' ') or ''
symbols[i] = fmt('%s%s', symbol, name)
end
else
for i = 1, len do
local name = kind_order[i]
symbols[i] = symbol_map[name]
end
end
for k,v in pairs(symbols) do
require('vim.lsp.protocol').CompletionItemKind[k] = v
end
end
lspkind.presets = kind_presets
return lspkind