[nvim] refactor: move CompletionItems to cmp.lua

This commit is contained in:
David JULIEN 2022-05-01 14:43:00 +02:00
parent 8f73067a9b
commit f0596d3c80
3 changed files with 41 additions and 41 deletions

View File

@ -17,6 +17,45 @@ end
-- If you want insert `(` after select function or method item -- If you want insert `(` after select function or method item
cmp.event:on( 'confirm_done', cmp_autopairs.on_confirm_done({ map_char = { tex = '' } })) cmp.event:on( 'confirm_done', cmp_autopairs.on_confirm_done({ map_char = { tex = '' } }))
-- Custom item icons
local icons = {
Class = "",
Color = "",
Constant = " µ ",
Constructor = "",
Enum = "",
EnumMember = "",
Event = "",
Field = "",
File = "",
Folder = "",
Function = "",
Keyword = "",
Interface = "",
Method = "",
Module = "",
Operator = "",
Property = "",
Reference = "",
Snippet = "",
Struct = "",
Text = "",
TypeParameter = "",
Unit = "",
Value = "",
Variable = "",
}
local function icons_setup()
local kinds = vim.lsp.protocol.CompletionItemKind
for i, kind in ipairs(kinds) do
kinds[i] = icons[kind] or kind
end
end
cmp.setup { cmp.setup {
completion = { completion = {
autocomplete = false autocomplete = false
@ -33,6 +72,7 @@ cmp.setup {
}, },
formatting = { formatting = {
format = function(entry, vim_item) format = function(entry, vim_item)
vim_item.kind = icons[vim_item.kind]
vim_item.menu = ({ vim_item.menu = ({
nvim_lsp = "[lsp]", nvim_lsp = "[lsp]",
nvim_lua = "[nvim]", nvim_lua = "[nvim]",

View File

@ -3,8 +3,6 @@
-- License : GPLv3 -- License : GPLv3
-- Description : neovim lsp config file -- Description : neovim lsp config file
local M = {}
vim.fn.sign_define( vim.fn.sign_define(
"DiagnosticSignError", "DiagnosticSignError",
{ {
@ -37,41 +35,3 @@ vim.fn.sign_define(
numhl = "DiagnosticSignInfo" numhl = "DiagnosticSignInfo"
} }
) )
M.icons = {
Class = "",
Color = "",
Constant = " µ ",
Constructor = "",
Enum = "",
EnumMember = "",
Event = "",
Field = "",
File = "",
Folder = "",
Function = "",
Keyword = "",
Interface = "",
Method = "",
Module = "",
Operator = "",
Property = "",
Reference = "",
Snippet = "",
Struct = "",
Text = "",
TypeParameter = "",
Unit = "",
Value = "",
Variable = "",
}
function M.setup()
local kinds = vim.lsp.protocol.CompletionItemKind
for i, kind in ipairs(kinds) do
kinds[i] = M.icons[kind] or kind
end
end
return M

View File

@ -58,7 +58,7 @@ return require("packer").startup(function()
requires = { requires = {
"neovim/nvim-lspconfig", "neovim/nvim-lspconfig",
config = function() config = function()
require("plugin.lsp_config").setup() end require("plugin.lsp_config") end
}, },
config = function() require("plugin.lsp_installer") end config = function() require("plugin.lsp_installer") end
} }