101 lines
3.7 KiB
Lua
101 lines
3.7 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({
|
|
behavior = cmp.ConfirmBehavior.Replace,
|
|
select = false,
|
|
}),
|
|
['<Tab>'] = cmp.mapping(function(fallback)
|
|
if cmp.visible() then
|
|
cmp.select_next_item()
|
|
elseif require('luasnip').expandable() then
|
|
luasnip.expand()
|
|
elseif luasnip.expand_or_jumpable() then
|
|
luasnip.expand_or_jump()
|
|
else
|
|
fallback()
|
|
end
|
|
end, { 'i', 's' }),
|
|
['<S-Tab>'] = cmp.mapping(function(fallback)
|
|
if cmp.visible() then
|
|
cmp.select_prev_item()
|
|
elseif require('luasnip').jumpable(-1) then
|
|
luasnip.jump(-1)
|
|
else
|
|
fallback()
|
|
end
|
|
end, { 'i', 's' }),
|
|
}),
|
|
sources = cmp.config.sources({
|
|
{ name = 'nvim_lsp' },
|
|
{ name = 'luasnip' }, -- For luasnip users.
|
|
{ name = 'codeium' },
|
|
}, {
|
|
{ name = 'buffer' },
|
|
}),
|
|
formatting = {
|
|
format = lspkind.cmp_format({
|
|
mode = 'symbol',
|
|
maxwidth = 50,
|
|
ellipsis_char = '...',
|
|
show_labelDetails = true,
|
|
|
|
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,
|
|
},
|
|
}
|