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
|
||||
|
||||
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 = {
|
||||
expand = function(args)
|
||||
luasnip.lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
mapping = {
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
['<C-d>'] = 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' }),
|
||||
|
@ -54,11 +64,13 @@ local default_cmp_opts = {
|
|||
'i',
|
||||
's',
|
||||
}),
|
||||
},
|
||||
}),
|
||||
window = {
|
||||
documentation = {
|
||||
border = user_config.border,
|
||||
winhighlight = 'FloatBorder:FloatBorder,Normal:Normal',
|
||||
},
|
||||
},
|
||||
experimental = {
|
||||
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.cmdline('/', {
|
||||
mapping = cmp.mapping.preset.cmdline(),
|
||||
sources = {
|
||||
{ name = 'buffer' },
|
||||
},
|
||||
|
@ -112,6 +125,7 @@ cmp.setup.filetype('gitcommit', {
|
|||
})
|
||||
|
||||
-- cmp.setup.cmdline(':', {
|
||||
-- mapping = cmp.mapping.preset.cmdline(),
|
||||
-- sources = cmp.config.sources({
|
||||
-- { name = 'path' },
|
||||
-- }, {
|
||||
|
|
Loading…
Add table
Reference in a new issue