local ok, cmp = pcall(require, "cmp") if not ok then return end local luasnip_ok, luasnip = pcall(require, "luasnip") if not luasnip_ok then vim.notify("Luasnip is required for nvim-cmp to work", vim.log.levels.WARN) end local lspkind = require "lspkind" cmp.setup { snippet = { expand = function(args) luasnip.lsp_expand(args.body) end, }, mapping = cmp.mapping.preset.insert { [""] = cmp.mapping(cmp.mapping.scroll_docs(4, { "i", "c" })), [""] = cmp.mapping(cmp.mapping.scroll_docs(-4, { "i", "c" })), [""] = cmp.mapping(cmp.mapping.complete {}, { "i", "c" }), [""] = cmp.mapping.close(), [""] = cmp.mapping.confirm { select = true }, }, sources = cmp.config.sources({ { name = "nvim_lsp" }, }, { { name = "buffer" }, { name = "path" }, }), formatting = { format = lspkind.cmp_format(), }, } cmp.setup.cmdline(":", { mapping = cmp.mapping.preset.cmdline(), sources = cmp.config.sources({ { name = "path" }, }, { { name = "cmdline" }, }), })