feat: update cmp integration
This commit is contained in:
parent
6eb01f3404
commit
95568785f4
1 changed files with 19 additions and 5 deletions
|
@ -10,12 +10,22 @@ local has_words_before = function()
|
||||||
end
|
end
|
||||||
|
|
||||||
local default_cmp_opts = {
|
local default_cmp_opts = {
|
||||||
|
enabled = function()
|
||||||
|
-- disable completion in comments
|
||||||
|
local context = require('cmp.config.context')
|
||||||
|
-- keep command mode completion enabled when cursor is in a comment
|
||||||
|
if vim.api.nvim_get_mode().mode == 'c' then
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
return not context.in_treesitter_capture('comment') and not context.in_syntax_group('Comment')
|
||||||
|
end
|
||||||
|
end,
|
||||||
snippet = {
|
snippet = {
|
||||||
expand = function(args)
|
expand = function(args)
|
||||||
luasnip.lsp_expand(args.body)
|
luasnip.lsp_expand(args.body)
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
mapping = {
|
mapping = cmp.mapping.preset.insert({
|
||||||
['<C-d>'] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }),
|
['<C-d>'] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }),
|
||||||
['<C-u>'] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }),
|
['<C-u>'] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }),
|
||||||
['<C-Space>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }),
|
['<C-Space>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }),
|
||||||
|
@ -54,11 +64,13 @@ local default_cmp_opts = {
|
||||||
'i',
|
'i',
|
||||||
's',
|
's',
|
||||||
}),
|
}),
|
||||||
},
|
}),
|
||||||
|
window = {
|
||||||
documentation = {
|
documentation = {
|
||||||
border = user_config.border,
|
border = user_config.border,
|
||||||
winhighlight = 'FloatBorder:FloatBorder,Normal:Normal',
|
winhighlight = 'FloatBorder:FloatBorder,Normal:Normal',
|
||||||
},
|
},
|
||||||
|
},
|
||||||
experimental = {
|
experimental = {
|
||||||
ghost_text = true,
|
ghost_text = true,
|
||||||
},
|
},
|
||||||
|
@ -97,6 +109,7 @@ vim.api.nvim_create_autocmd('FileType', {
|
||||||
cmp.setup(u.merge(default_cmp_opts, user_config.nvim_cmp or {}))
|
cmp.setup(u.merge(default_cmp_opts, user_config.nvim_cmp or {}))
|
||||||
|
|
||||||
cmp.setup.cmdline('/', {
|
cmp.setup.cmdline('/', {
|
||||||
|
mapping = cmp.mapping.preset.cmdline(),
|
||||||
sources = {
|
sources = {
|
||||||
{ name = 'buffer' },
|
{ name = 'buffer' },
|
||||||
},
|
},
|
||||||
|
@ -112,6 +125,7 @@ cmp.setup.filetype('gitcommit', {
|
||||||
})
|
})
|
||||||
|
|
||||||
-- cmp.setup.cmdline(':', {
|
-- cmp.setup.cmdline(':', {
|
||||||
|
-- mapping = cmp.mapping.preset.cmdline(),
|
||||||
-- sources = cmp.config.sources({
|
-- sources = cmp.config.sources({
|
||||||
-- { name = 'path' },
|
-- { name = 'path' },
|
||||||
-- }, {
|
-- }, {
|
||||||
|
|
Loading…
Add table
Reference in a new issue