local luasnip = require("luasnip") local cmp = require'cmp' cmp.setup({ mapping = { [''] = cmp.mapping.select_prev_item(), [''] = cmp.mapping.select_next_item(), [''] = cmp.mapping.scroll_docs(-4), [''] = cmp.mapping.scroll_docs(4), [''] = cmp.mapping.complete(), [''] = cmp.mapping.abort(), [''] = cmp.mapping.confirm({ select = true }), [""] = cmp.mapping(function(fallback) if luasnip.expand_or_jumpable() then luasnip.expand_or_jump() elseif has_words_before() then cmp.complete() else fallback() end end, { "i", "s" }), [""] = cmp.mapping(function(fallback) if luasnip.jumpable(-1) then luasnip.jump(-1) else fallback() end end, { "i", "s" }), }, sources = { { name = 'nvim_lsp' }, { name = 'luasnip' }, { name = 'nvim_lua' }, { name = 'buffer' }, { name = 'path' }, }, window = { completion = cmp.config.window.bordered(), -- documentation = cmp.config.window.bordered(), }, formatting = { }, snippet = { expand = function(args) require'luasnip'.lsp_expand(args.body) end, }, experimental = { native_menu = false, ghost_text = true }, }) -- Set configuration for specific filetype. cmp.setup.filetype('gitcommit', { sources = cmp.config.sources({ { name = 'cmp_git' }, -- You can specify the `cmp_git` source if you were installed it. }, { { name = 'buffer' }, }) }) -- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore). 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' } }) })