comparison .chezmoitemplates/init.lua @ 594:e8615fbcf11b

Fix mappings for cmp
author zegervdv <zegervdv@me.com>
date Sun, 15 May 2022 11:34:13 +0200
parents ece4809c1313
children 1def7efdc619
comparison
equal deleted inserted replaced
593:ece4809c1313 594:e8615fbcf11b
300 expand = function(args) 300 expand = function(args)
301 luasnip.lsp_expand(args.body) 301 luasnip.lsp_expand(args.body)
302 end, 302 end,
303 }, 303 },
304 mapping = { 304 mapping = {
305 ['<C-p>'] = cmp.mapping.select_prev_item(), 305 ['<C-p>'] = { i = cmp.mapping.select_prev_item() },
306 ['<C-n>'] = cmp.mapping.select_next_item(), 306 ['<C-n>'] = { i = cmp.mapping.select_next_item() },
307 ['<C-d>'] = cmp.mapping.scroll_docs(-4), 307 ['<C-d>'] = { i = cmp.mapping.scroll_docs(-4) },
308 ['<C-y>'] = cmp.mapping.complete(), 308 ['<C-y>'] = { i = cmp.mapping.complete() },
309 ['<C-e>'] = cmp.mapping.close(), 309 ['<C-e>'] = { i = cmp.mapping.close() },
310 ['<CR>'] = cmp.mapping.confirm { 310 ['<CR>'] = { i = cmp.mapping.confirm { behavior = cmp.ConfirmBehavior.Replace } },
311 behavior = cmp.ConfirmBehavior.Replace, 311 ['<C-k>'] = { i = cmp.mapping.confirm { behavior = cmp.ConfirmBehavior.Replace } },
312 },
313 ['<Tab>'] = cmp.mapping(function(fallback)
314 if cmp.visible() then
315 cmp.select_next_item()
316 elseif luasnip.expand_or_jumpable() then
317 luasnip.expand_or_jump()
318 elseif has_words_before() then
319 cmp.complete()
320 else
321 fallback()
322 end
323 end, {
324 'i',
325 's',
326 }),
327
328 ['<S-Tab>'] = cmp.mapping(function(fallback)
329 if cmp.visible() then
330 cmp.select_prev_item()
331 elseif luasnip.jumpable(-1) then
332 luasnip.jump(-1)
333 else
334 fallback()
335 end
336 end, {
337 'i',
338 's',
339 }),
340 }, 312 },
341 sources = { 313 sources = {
342 { name = 'nvim_lsp' }, 314 { name = 'nvim_lsp' },
343 { name = 'nvim_lsp_signature_help' }, 315 { name = 'nvim_lsp_signature_help' },
344 { name = 'buffer', keyword_length = 5 }, 316 { name = 'buffer', keyword_length = 5 },
350 ghost_text = true, 322 ghost_text = true,
351 }, 323 },
352 } 324 }
353 325
354 cmp.setup.cmdline(':', { 326 cmp.setup.cmdline(':', {
355 mapping = cmp.mapping.preset.cmdline(), 327 mapping = cmp.mapping.preset.cmdline {
328 ['<C-p>'] = { c = cmp.mapping.select_prev_item() },
329 ['<C-n>'] = { c = cmp.mapping.select_next_item() },
330 ['<C-y>'] = { c = cmp.mapping.complete() },
331 },
356 sources = cmp.config.sources({ 332 sources = cmp.config.sources({
357 { name = 'path' }, 333 { name = 'path' },
358 }, { 334 }, {
359 { name = 'cmdline', keyword_length = 4 }, 335 { name = 'cmdline', keyword_length = 4 },
360 }), 336 }),