82 lines
3.5 KiB
Lua
82 lines
3.5 KiB
Lua
return {
|
|
{
|
|
'hrsh7th/cmp-nvim-lsp',
|
|
},
|
|
{
|
|
'hrsh7th/nvim-cmp',
|
|
|
|
dependencies = {
|
|
'saadparwaiz1/cmp_luasnip',
|
|
'hrsh7th/cmp-cmdline',
|
|
'L3MON4D3/LuaSnip',
|
|
'rafamadriz/friendly-snippets',
|
|
'onsails/lspkind.nvim',
|
|
},
|
|
event = 'InsertEnter',
|
|
config = function()
|
|
local cmp = require('cmp')
|
|
local lspkind = require('lspkind')
|
|
|
|
cmp.setup({
|
|
snippet = {
|
|
expand = function(args)
|
|
require('luasnip').lsp_expand(args.body) -- For `luasnip` users.
|
|
require('luasnip.loaders.from_vscode').lazy_load()
|
|
end,
|
|
},
|
|
window = {
|
|
completion = cmp.config.window.bordered(),
|
|
documentation = cmp.config.window.bordered(),
|
|
},
|
|
mapping = cmp.mapping.preset.insert({
|
|
['<C-b>'] = cmp.mapping.scroll_docs(-4),
|
|
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
|
['<C-Space>'] = cmp.mapping.complete(),
|
|
['<C-e>'] = cmp.mapping.abort(),
|
|
['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
|
|
}),
|
|
sources = cmp.config.sources({
|
|
{ name = 'nvim_lsp' },
|
|
{ name = 'luasnip' }, -- For luasnip users.
|
|
{ name = 'codeium' },
|
|
}, {
|
|
{ name = 'buffer' },
|
|
}),
|
|
formatting = {
|
|
format = lspkind.cmp_format({
|
|
mode = 'symbol', -- show only symbol annotations
|
|
maxwidth = 50, -- prevent the popup from showing more than provided characters (e.g 50 will not show more than 50 characters)
|
|
-- can also be a function to dynamically calculate max width such as
|
|
-- maxwidth = function() return math.floor(0.45 * vim.o.columns) end,
|
|
ellipsis_char = '...', -- when popup menu exceed maxwidth, the truncated part would show ellipsis_char instead (must define maxwidth first)
|
|
show_labelDetails = true, -- show labelDetails in menu. Disabled by default
|
|
|
|
-- The function below will be called before any actual modifications from lspkind
|
|
-- so that you can provide more controls on popup customization. (See [#30](https://github.com/onsails/lspkind-nvim/pull/30))
|
|
before = function(entry, vim_item)
|
|
return vim_item
|
|
end,
|
|
}),
|
|
},
|
|
})
|
|
cmp.setup.cmdline({ '/', '?' }, {
|
|
mapping = cmp.mapping.preset.cmdline(),
|
|
sources = {
|
|
{ name = 'buffer' },
|
|
},
|
|
})
|
|
|
|
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
|
|
cmp.setup.cmdline(':', {
|
|
mapping = cmp.mapping.preset.cmdline(),
|
|
sources = cmp.config.sources({
|
|
{ name = 'path' },
|
|
}, {
|
|
{ name = 'cmdline' },
|
|
}),
|
|
matching = { disallow_symbol_nonprefix_matching = false },
|
|
})
|
|
end,
|
|
},
|
|
}
|