------------------------------------------------------------------------------- -- - LSP completion config - ------------------------------------------------------------------------------- -- Set completeopt to have a better completion experience vim.o.completeopt = "menu,menuone,noselect" local cmp = require("cmp") local luasnip = require("luasnip") cmp.setup({ snippet = { expand = function(args) require("luasnip").lsp_expand(args.body) end, }, 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() else fallback() end end, [""] = function(fallback) if cmp.visible() then cmp.select_prev_item() else fallback() end end, [""] = cmp.mapping(function(fallback) if luasnip.jumpable(1) then luasnip.jump(1) 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 = "nvim_lua" }, { name = "path" }, { name = "luasnip" }, { name = "buffer" }, }, })