local present, cmp = pcall(require, "cmp") if not present then return end local lspkind = require("lspkind") cmp.setup { snippet = { expand = function(args) require("luasnip").lsp_expand(args.body) end, }, formatting = { format = lspkind.cmp_format({ with_text = false, maxwidth = 50 }) }, mapping = { [""] = cmp.mapping.scroll_docs(-4), [""] = cmp.mapping.scroll_docs(4), [""] = cmp.mapping.complete(), [""] = cmp.mapping.close(), [""] = cmp.mapping.confirm({ select = true }), [""] = function(fallback) if cmp.visible() then cmp.select_next_item() elseif require("luasnip").expand_or_jumpable() then vim.fn.feedkeys(vim.api.nvim_replace_termcodes("luasnip-expand-or-jump", true, true, true), "") else fallback() end end, [""] = function(fallback) if cmp.visible() then cmp.select_prev_item() elseif require("luasnip").jumpable(-1) then vim.fn.feedkeys(vim.api.nvim_replace_termcodes("luasnip-jump-prev", true, true, true), "") else fallback() end end, }, sources = { { name = "luasnip" }, { name = "buffer" }, { name = "path" }, { name = "nvim_lsp" }, { name = "nvim_lua" } }, }