1
0
mirror of https://github.com/jdhao/nvim-config.git synced 2025-06-08 14:14:33 +02:00

add lspkind.nvim

This commit is contained in:
jdhao 2021-10-23 01:13:41 +08:00
parent 29c8e97338
commit 613e2fa489
2 changed files with 20 additions and 2 deletions

View File

@ -1,5 +1,6 @@
-- Setup nvim-cmp. -- Setup nvim-cmp.
local cmp = require'cmp' local cmp = require'cmp'
local lspkind = require'lspkind'
cmp.setup({ cmp.setup({
snippet = { snippet = {
@ -31,6 +32,7 @@ cmp.setup({
sources = { sources = {
{ name = 'nvim_lsp' }, -- For nvim-lsp { name = 'nvim_lsp' }, -- For nvim-lsp
{ name = 'ultisnips' }, -- For ultisnips user. { name = 'ultisnips' }, -- For ultisnips user.
{ name = 'nvim_lua' }, -- for nvim lua function
{ name = 'path' }, -- for path completion { name = 'path' }, -- for path completion
{ name = 'emoji', insert = true, } -- emoji completion { name = 'emoji', insert = true, } -- emoji completion
}, },
@ -40,5 +42,19 @@ cmp.setup({
}, },
experimental = { experimental = {
ghost_text = false ghost_text = false
} },
formatting = {
format = lspkind.cmp_format({
with_text = false,
menu = {
nvim_lsp = "[LSP]",
ultisnips = "[US]",
nvim_lua = "[Lua]",
path = "[Path]",
emoji = "[Emoji]",
},
}),
},
}) })
vim.cmd("hi link CmpItemMenu Comment")

View File

@ -27,8 +27,9 @@ require("packer").startup({
function(use) function(use)
use({"wbthomason/packer.nvim", opt = true}) use({"wbthomason/packer.nvim", opt = true})
use {"onsails/lspkind-nvim", event = "BufEnter"}
-- auto-completion engine -- auto-completion engine
use {"hrsh7th/nvim-cmp", event = "BufEnter", config = [[require('config.nvim-cmp')]]} use {"hrsh7th/nvim-cmp", after = "lspkind-nvim", config = [[require('config.nvim-cmp')]]}
-- nvim-cmp completion sources -- nvim-cmp completion sources
use {"hrsh7th/cmp-nvim-lsp", after = "nvim-cmp"} use {"hrsh7th/cmp-nvim-lsp", after = "nvim-cmp"}
@ -36,6 +37,7 @@ require("packer").startup({
-- nvim-lsp configuration (it relies on cmp-nvim-lsp, so it should be loaded after cmp-nvim-lsp). -- nvim-lsp configuration (it relies on cmp-nvim-lsp, so it should be loaded after cmp-nvim-lsp).
use({ "neovim/nvim-lspconfig", after = "cmp-nvim-lsp", config = [[require('config.lsp')]] }) use({ "neovim/nvim-lspconfig", after = "cmp-nvim-lsp", config = [[require('config.lsp')]] })
use {"hrsh7th/cmp-nvim-lua", after = "nvim-cmp"}
use {"hrsh7th/cmp-path", after = "nvim-cmp"} use {"hrsh7th/cmp-path", after = "nvim-cmp"}
use {"quangnguyen30192/cmp-nvim-ultisnips", after = {'nvim-cmp', 'ultisnips'}} use {"quangnguyen30192/cmp-nvim-ultisnips", after = {'nvim-cmp', 'ultisnips'}}
if vim.g.is_mac then if vim.g.is_mac then