local cmp = require("cmp") local luasnip = require("luasnip") local lspkind = require("lspkind") require("luasnip/loaders/from_vscode").lazy_load() cmp.setup({ completion = { completeopt = "menu,menuone,preview,noselect", }, window = { -- making ui stuff for completion bordered completion = cmp.config.window.bordered(), documentation = cmp.config.window.bordered(), }, -- configure lspkind for vs-code like pictograms in completion menu formatting = { format = lspkind.cmp_format({ maxwidth = 50, ellipsis_char = "...", }), }, snippet = { -- configure how nvim-cmp interacts with snippet engine expand = function(args) luasnip.lsp_expand(args.body) end, }, mapping = { [""] = cmp.mapping.select_prev_item(), -- previous suggestion [""] = cmp.mapping.select_next_item(), -- next suggestion [""] = cmp.mapping.scroll_docs(-4), [""] = cmp.mapping.scroll_docs(4), [""] = cmp.mapping.complete(), -- show completion suggestions [""] = cmp.config.disable, [""] = cmp.mapping({ -- close completion window i = cmp.mapping.abort(), c = cmp.mapping.close(), }), [""] = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = false, }), [""] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_next_item() elseif luasnip.expandable() then luasnip.expand() 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" }), }, cmp.setup.cmdline(":", { mapping = cmp.mapping.preset.cmdline(), sources = { { name = "cmdline" }, }, }), -- cmp.setup.cmdline("/", { -- mapping = cmp.mapping.preset.cmdline(), -- sources = { -- { name = "buffer" }, -- }, -- }), -- sources for autocompletion sources = { { name = "nvim_lsp" }, { name = "nvim_lsp_signature_help" }, -- parameter hints { name = "luasnip" }, -- snippets { name = "buffer" }, -- text within current buffer { name = "path" }, -- file system paths { name = "codeium" }, -- AI for autocompletion -- { name = "calc" }, --for maths calculations }, })