a lot more stuff
This commit is contained in:
@ -1,14 +1,22 @@
|
||||
local lsp = require('core.lsp.functions')
|
||||
|
||||
return { 'hrsh7th/nvim-cmp',
|
||||
requires = {
|
||||
'nvim-treesitter/nvim-treesitter',
|
||||
'lukas-reineke/cmp-under-comparator' -- better results
|
||||
'lukas-reineke/cmp-under-comparator', -- better results
|
||||
'xzbdmw/colorful-menu.nvim' -- fancy colors
|
||||
},
|
||||
|
||||
-- suppliers for completions (they require nvim-cmp to be loaded before they are)
|
||||
deps = {
|
||||
'hrsh7th/cmp-buffer', -- buffers
|
||||
'FelipeLema/cmp-async-path', -- path
|
||||
'hrsh7th/cmp-nvim-lsp', -- lsp
|
||||
{ 'hrsh7th/cmp-nvim-lsp',
|
||||
function()
|
||||
-- add lsp capabilities
|
||||
lsp.add_capabilities(require('cmp_nvim_lsp').default_capabilities())
|
||||
end
|
||||
}, -- lsp
|
||||
'hrsh7th/cmp-nvim-lsp-signature-help', -- completion information
|
||||
{ 'L3MON4D3/cmp-luasnip-choice', -- luasnip
|
||||
requires = 'L3MON4D3/LuaSnip'
|
||||
@ -19,6 +27,7 @@ return { 'hrsh7th/nvim-cmp',
|
||||
local cmp = require('cmp')
|
||||
local luasnip = require('luasnip')
|
||||
|
||||
-- setup cmp
|
||||
cmp.setup {
|
||||
-- disable when in comments
|
||||
enabled = function()
|
||||
@ -44,8 +53,8 @@ return { 'hrsh7th/nvim-cmp',
|
||||
-- how to sort results
|
||||
sorting = {
|
||||
comparators = {
|
||||
cmp.config.compare.offset,
|
||||
cmp.config.compare.exact,
|
||||
cmp.config.compare.offset,
|
||||
cmp.config.compare.score,
|
||||
require('cmp-under-comparator').under,
|
||||
cmp.config.compare.kind,
|
||||
@ -80,16 +89,24 @@ return { 'hrsh7th/nvim-cmp',
|
||||
formatting = {
|
||||
fields = { 'menu', 'abbr', 'kind' },
|
||||
format = function(entry, item)
|
||||
local hl_info = require("colorful-menu").cmp_highlights(entry)
|
||||
local menu_icon = {
|
||||
nvim_lsp = 'λ',
|
||||
nvim_lua = 'v',
|
||||
luasnip = '%',
|
||||
buffer = '@',
|
||||
path = '#',
|
||||
async_path = '#'
|
||||
}
|
||||
|
||||
-- add a little icon
|
||||
item.menu = menu_icon[entry.source.name]
|
||||
|
||||
-- add highlights
|
||||
if hl_info ~= nil then
|
||||
item.abbr_hl_group = hl_info.highlights
|
||||
item.abbr = hl_info.text
|
||||
end
|
||||
|
||||
return item
|
||||
end
|
||||
},
|
||||
@ -107,25 +124,14 @@ return { 'hrsh7th/nvim-cmp',
|
||||
|
||||
-- mappings
|
||||
mapping = cmp.mapping.preset.insert {
|
||||
["<C-y>"] = cmp.mapping(function()
|
||||
cmp.confirm({ select = true })
|
||||
end, { "i", "c" }),
|
||||
|
||||
["<C-n>"] = cmp.mapping(function()
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
end
|
||||
end),
|
||||
|
||||
["<C-p>"] = cmp.mapping(function()
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
end
|
||||
end),
|
||||
|
||||
["<C-y>"] = cmp.mapping.confirm {
|
||||
select = true
|
||||
},
|
||||
["<C-n>"] = cmp.mapping.select_next_item(),
|
||||
["<C-p>"] = cmp.mapping.select_prev_item(),
|
||||
["<C-u>"] = cmp.mapping.scroll_docs(-4),
|
||||
["<C-d>"] = cmp.mapping.scroll_docs(4),
|
||||
['<ESC>'] = cmp.mapping.close()
|
||||
["<ESC>"] = cmp.mapping.close()
|
||||
}
|
||||
}
|
||||
end
|
||||
|
Reference in New Issue
Block a user