Files
nvim/lua/lsp/kind.lua
T

90 lines
1.9 KiB
Lua

local M = {}
M.ICONS = {
Text = "󰉿",
Method = "󰊕",
Function = "󰊕",
Constructor = "󰒓",
Field = "󰜢",
Variable = "󰆦",
Property = "󰖷",
Class = "󱡠",
Interface = "󱡠",
Struct = "󱡠",
Module = "󰅩",
Unit = "󰪚",
Value = "󰦨",
Enum = "󰦨",
EnumMember = "󰦨",
Keyword = "󰻾",
Constant = "󰏿",
Snippet = "󱄽",
Color = "󰏘",
File = "󰈔",
Reference = "󰬲",
Folder = "󰉋",
Event = "󱐋",
Operator = "󰪚",
TypeParameter = "󰬛",
}
local DEFAULT_HIGHLIGHTS = {
Method = "Function",
Function = "Function",
Constructor = "Function",
Field = "Identifier",
Variable = "Identifier",
Property = "Identifier",
Class = "Type",
Interface = "Type",
Struct = "Type",
Enum = "Type",
TypeParameter = "Type",
Keyword = "Keyword",
Operator = "Keyword",
Event = "Keyword",
Constant = "Constant",
EnumMember = "Constant",
Value = "Constant",
Unit = "Constant",
Text = "String",
Snippet = "String",
Color = "String",
Module = "Directory",
File = "Directory",
Folder = "Directory",
Reference = "Special",
}
---@param kind? integer
---@return string? icon
---@return string? hl
function M.get(kind)
if not kind then
return nil, nil
end
local name = vim.lsp.protocol.CompletionItemKind[kind]
if not name or not M.ICONS[name] then
return nil, nil
end
return M.ICONS[name], "OwLspKind" .. name
end
local function register_highlights()
for name in pairs(M.ICONS) do
vim.api.nvim_set_hl(0, "OwLspKind" .. name, {
link = DEFAULT_HIGHLIGHTS[name] or "Pmenu",
default = true,
})
end
end
register_highlights()
vim.api.nvim_create_autocmd("ColorScheme", {
group = vim.api.nvim_create_augroup("ow.lsp.kind", { clear = true }),
callback = register_highlights,
})
return M