Some checks failed
Detach Plugins / check (FlyGrep.vim) (push) Has been cancelled
Detach Plugins / check (GitHub.vim) (push) Has been cancelled
Detach Plugins / check (JavaUnit.vim) (push) Has been cancelled
Detach Plugins / check (SourceCounter.vim) (push) Has been cancelled
Detach Plugins / check (cpicker.nvim) (push) Has been cancelled
Detach Plugins / check (dein-ui.vim) (push) Has been cancelled
Detach Plugins / check (git.vim) (push) Has been cancelled
Detach Plugins / check (iedit.vim) (push) Has been cancelled
Detach Plugins / check (scrollbar.vim) (push) Has been cancelled
Detach Plugins / check (vim-chat) (push) Has been cancelled
Detach Plugins / check (vim-cheat) (push) Has been cancelled
Detach Plugins / check (vim-todo) (push) Has been cancelled
Detach Plugins / check (xmake.vim) (push) Has been cancelled
test / Linux (nvim, nightly) (push) Has been cancelled
test / Linux (nvim, v0.3.8) (push) Has been cancelled
test / Linux (nvim, v0.4.0) (push) Has been cancelled
test / Linux (nvim, v0.4.2) (push) Has been cancelled
test / Linux (nvim, v0.4.3) (push) Has been cancelled
test / Linux (nvim, v0.4.4) (push) Has been cancelled
test / Linux (nvim, v0.5.0) (push) Has been cancelled
test / Linux (nvim, v0.5.1) (push) Has been cancelled
test / Linux (nvim, v0.6.0) (push) Has been cancelled
test / Linux (nvim, v0.6.1) (push) Has been cancelled
test / Linux (nvim, v0.7.0) (push) Has been cancelled
test / Linux (nvim, v0.7.2) (push) Has been cancelled
test / Linux (nvim, v0.8.0) (push) Has been cancelled
test / Linux (nvim, v0.8.1) (push) Has been cancelled
test / Linux (nvim, v0.8.2) (push) Has been cancelled
test / Linux (nvim, v0.8.3) (push) Has been cancelled
test / Linux (nvim, v0.9.0) (push) Has been cancelled
test / Linux (nvim, v0.9.1) (push) Has been cancelled
test / Linux (true, vim, v7.4.052) (push) Has been cancelled
test / Linux (true, vim, v7.4.1689) (push) Has been cancelled
test / Linux (true, vim, v7.4.629) (push) Has been cancelled
test / Linux (true, vim, v8.0.0027) (push) Has been cancelled
test / Linux (true, vim, v8.0.0183) (push) Has been cancelled
test / Linux (vim, nightly) (push) Has been cancelled
test / Linux (vim, v8.0.0184) (push) Has been cancelled
test / Linux (vim, v8.0.1453) (push) Has been cancelled
test / Linux (vim, v8.1.2269) (push) Has been cancelled
test / Linux (vim, v8.2.2434) (push) Has been cancelled
test / Linux (vim, v8.2.3995) (push) Has been cancelled
test / Windows (nvim, nightly) (push) Has been cancelled
test / Windows (nvim, v0.3.8) (push) Has been cancelled
test / Windows (nvim, v0.4.2) (push) Has been cancelled
test / Windows (nvim, v0.4.3) (push) Has been cancelled
test / Windows (nvim, v0.4.4) (push) Has been cancelled
test / Windows (nvim, v0.5.0) (push) Has been cancelled
test / Windows (nvim, v0.5.1) (push) Has been cancelled
test / Windows (nvim, v0.6.0) (push) Has been cancelled
test / Windows (nvim, v0.6.1) (push) Has been cancelled
test / Windows (nvim, v0.7.0) (push) Has been cancelled
test / Windows (nvim, v0.7.2) (push) Has been cancelled
test / Windows (nvim, v0.8.0) (push) Has been cancelled
test / Windows (nvim, v0.8.1) (push) Has been cancelled
test / Windows (nvim, v0.8.2) (push) Has been cancelled
test / Windows (nvim, v0.8.3) (push) Has been cancelled
test / Windows (nvim, v0.9.0) (push) Has been cancelled
test / Windows (nvim, v0.9.1) (push) Has been cancelled
test / Windows (vim, nightly) (push) Has been cancelled
test / Windows (vim, v7.4.1185) (push) Has been cancelled
test / Windows (vim, v7.4.1689) (push) Has been cancelled
test / Windows (vim, v8.0.0027) (push) Has been cancelled
test / Windows (vim, v8.0.1453) (push) Has been cancelled
test / Windows (vim, v8.1.2269) (push) Has been cancelled
test / Windows (vim, v8.2.2434) (push) Has been cancelled
test / Windows (vim, v8.2.3995) (push) Has been cancelled
docker / docker (push) Has been cancelled
mirror / check (coding) (push) Has been cancelled
mirror / check (gitee) (push) Has been cancelled
mirror / check (gitlab) (push) Has been cancelled
144 lines
3.1 KiB
Lua
144 lines
3.1 KiB
Lua
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'
|
|
}
|
|
local kind_len = 25
|
|
|
|
-- default true
|
|
local function opt_with_text(opts)
|
|
return opts == nil or opts['with_text'] == nil or opts['with_text']
|
|
end
|
|
|
|
-- default 'default'
|
|
local function opt_preset(opts)
|
|
local preset
|
|
if opts == nil or opts['preset'] == nil then
|
|
preset = 'default'
|
|
else
|
|
preset = opts['preset']
|
|
end
|
|
return preset
|
|
end
|
|
|
|
function lspkind.init(opts)
|
|
local preset = opt_preset(opts)
|
|
|
|
local symbol_map = kind_presets[preset]
|
|
lspkind.symbol_map = (opts and opts['symbol_map'] and
|
|
vim.tbl_extend('force', symbol_map, opts['symbol_map'])) or symbol_map
|
|
|
|
local symbols = {}
|
|
local len = kind_len
|
|
for i = 1, len do
|
|
local name = kind_order[i]
|
|
symbols[i] = lspkind.symbolic(name, opts)
|
|
end
|
|
|
|
for k,v in pairs(symbols) do
|
|
require('vim.lsp.protocol').CompletionItemKind[k] = v
|
|
end
|
|
end
|
|
|
|
lspkind.presets = kind_presets
|
|
lspkind.symbol_map = kind_presets.default
|
|
|
|
function lspkind.symbolic(kind, opts)
|
|
local with_text = opt_with_text(opts)
|
|
|
|
local symbol = lspkind.symbol_map[kind]
|
|
if with_text == true then
|
|
symbol = symbol and (symbol .. ' ') or ''
|
|
return fmt('%s%s', symbol, kind)
|
|
else
|
|
return symbol
|
|
end
|
|
end
|
|
|
|
function lspkind.cmp_format(opts)
|
|
if opts == nil then
|
|
opts = {}
|
|
end
|
|
if opts.preset or opts.symbol_map then
|
|
lspkind.init(opts)
|
|
end
|
|
|
|
return function(entry, vim_item)
|
|
vim_item.kind = lspkind.symbolic(vim_item.kind, opts)
|
|
|
|
if opts.menu ~= nil then
|
|
vim_item.menu = opts.menu[entry.source.name]
|
|
end
|
|
|
|
if opts.maxwidth ~= nil then
|
|
vim_item.abbr = string.sub(vim_item.abbr, 1, opts.maxwidth)
|
|
end
|
|
|
|
return vim_item
|
|
end
|
|
end
|
|
|
|
return lspkind
|