feat(lsp): custom omnifunc
This commit is contained in:
@@ -0,0 +1,90 @@
|
||||
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",
|
||||
}
|
||||
|
||||
--- Look up icon and highlight group for an LSP CompletionItemKind number.
|
||||
---@param kind integer?
|
||||
---@return string icon empty string if the kind is unknown
|
||||
---@return string? hl nil if the kind is unknown
|
||||
function M.get(kind)
|
||||
if not kind then
|
||||
return "", nil
|
||||
end
|
||||
local name = vim.lsp.protocol.CompletionItemKind[kind]
|
||||
if not name or not M.ICONS[name] then
|
||||
return "", 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
|
||||
Reference in New Issue
Block a user