-- lua/plugins/cmp.lua local cmp = require("cmp") local luasnip = require("luasnip") -- Setup nvim-cmp. cmp.setup({ snippet = { -- REQUIRED - you must specify a snippet engine expand = function(args) luasnip.lsp_expand(args.body) -- Use LuaSnip to expand snippets end, }, mapping = cmp.mapping.preset.insert({ [''] = cmp.mapping.select_prev_item(), -- Move up on suggestion list [''] = cmp.mapping.select_next_item(), -- Move down on suggestion list [''] = cmp.mapping.scroll_docs(-4), -- Scroll docs up [''] = cmp.mapping.scroll_docs(4), -- Scroll docs down [''] = cmp.mapping.complete(), -- Trigger completion menu [''] = cmp.mapping.abort(), -- Close completion window [''] = cmp.mapping.confirm({ select = true }), -- Enter to confirm selection [''] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_next_item() elseif luasnip.expand_or_jumpable() then luasnip.expand_or_jump() else fallback() end end, { "i", "s" }), [''] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_prev_item() elseif luasnip.jumpable(-1) then luasnip.jump(-1) else fallback() end end, { "i", "s" }), }), sources = cmp.config.sources({ { name = 'nvim_lsp' }, -- LSP suggestions (your language servers) { name = 'luasnip' }, -- Snippets suggestions { name = 'buffer' }, -- Words from open buffers { name = 'path' }, -- File paths }), })