78 lines
1.9 KiB
Lua
78 lines
1.9 KiB
Lua
local cmp = require('cmp')
|
|
|
|
vim.cmd([[
|
|
autocmd FileType TelescopePrompt lua require('cmp').setup.buffer { enabled = false }
|
|
]])
|
|
|
|
cmp.setup({
|
|
snippet = {
|
|
expand = function(args)
|
|
require'luasnip'.lsp_expand(args.body)
|
|
end,
|
|
},
|
|
mapping = {
|
|
['<C-d>'] = cmp.mapping.scroll_docs(-4),
|
|
['<C-u>'] = cmp.mapping.scroll_docs(4),
|
|
['<C-Space>'] = cmp.mapping.complete(),
|
|
['<C-e>'] = cmp.mapping.close(),
|
|
['<CR>'] = cmp.mapping.confirm({
|
|
behavior = cmp.ConfirmBehavior.Replace,
|
|
select = true,
|
|
}),
|
|
['<Tab>'] = function(fallback)
|
|
if cmp.visible() then
|
|
cmp.select_next_item()
|
|
else
|
|
fallback()
|
|
end
|
|
end,
|
|
['<S-Tab>'] = function(fallback)
|
|
if cmp.visible() then
|
|
cmp.select_prev_item()
|
|
else
|
|
fallback()
|
|
end
|
|
end,
|
|
},
|
|
documentation = {
|
|
border = 'single',
|
|
winhighlight = 'FloatBorder:FloatBorder,Normal:Normal',
|
|
},
|
|
experimental = {
|
|
ghost_text = true,
|
|
},
|
|
sources = {
|
|
{ name = 'nvim_lsp' },
|
|
{ name = 'buffer' },
|
|
{ name = 'nvim_lua' },
|
|
{ name = 'path' },
|
|
{ name = 'luasnip' },
|
|
},
|
|
formatting = {
|
|
format = require('lspkind').cmp_format({
|
|
with_text = true,
|
|
menu = {
|
|
buffer = '[buf]',
|
|
nvim_lsp = '[LSP]',
|
|
nvim_lua = '[VimApi]',
|
|
path = '[path]',
|
|
luasnip = '[snip]',
|
|
},
|
|
}),
|
|
},
|
|
})
|
|
|
|
require('nvim-autopairs').setup({
|
|
disable_filetype = { 'TelescopePrompt', 'vim' },
|
|
})
|
|
|
|
require('nvim-autopairs.completion.cmp').setup({
|
|
map_cr = true, -- map <CR> on insert mode
|
|
map_complete = true, -- it will auto insert `(` (map_char) after select function or method item
|
|
auto_select = true, -- automatically select the first item
|
|
insert = false, -- use insert confirm behavior instead of replace
|
|
map_char = { -- modifies the function or method delimiter by filetypes
|
|
all = '(',
|
|
tex = '{',
|
|
},
|
|
})
|