就是给片段引擎加上个类似 VSCode 的类型图标,反正就是好看。颜值就是动力
截屏2021-09-04 21.50.39.png在 coc-settings.json
中添加下面的代码(确保使用修补后的字体: 类似 Nerd Font)
{
"suggest.completionItemKindLabels": {
"keyword": "\uf1de",
"variable": "\ue79b",
"value": "\uf89f",
"operator": "\u03a8",
"function": "\u0192",
"reference": "\ufa46",
"constant": "\uf8fe",
"method": "\uf09a",
"struct": "\ufb44",
"class": "\uf0e8",
"interface": "\uf417",
"text": "\ue612",
"enum": "\uf435",
"enumMember": "\uf02b",
"module": "\uf40d",
"color": "\ue22b",
"property": "\ue624",
"field": "\uf9be",
"unit": "\uf475",
"event": "\ufacd",
"file": "\uf723",
"folder": "\uf114",
"snippet": "\ue60b",
"typeParameter": "\uf728",
"default": "\uf29c"
}
}
neovim 的内置 LSP 也可以配合使用。配合在 nvim-cmp
上,不需要安装插件的
-- filename: lspkind.lua
-- 不使用 lspkind 插件,只使用他它的图标
local M = {}
M.symbol_icons = {
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 = ""
}
return M
-- filename: nvimcmp.lua
local present, cmp = pcall(require, "cmp")
if not present then
return
end
cmp.setup {
snippet = {
expand = function(args)
-- 使用 luasnip 片段引擎
require("luasnip").lsp_expand(args.body)
end
},
-- 设置如何显示项目类型和来源的名称
formatting = {
format = function(entry, vim_item)
-- fancy icons and a name of kind
vim_item.kind = string.format("%s %s", require("plugins.config.lspkind").symbol_icons[vim_item.kind], vim_item.kind)
-- set a name for each source
vim_item.menu = ({
buffer = "[BUF]",
nvim_lsp = "[LSP]",
luasnip = "[LS]",
nvim_lua = "[Lua]"
})[entry.source.name]
return vim_item
end
},
-- code
-- ...
}
网友评论