From 0a05888d992b37749f9aae25c7f63f2534ec1024 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Mon, 9 Oct 2023 10:05:57 +0200 Subject: [PATCH] fix(cmp): set default group_index to 1 to prevent issues with custom sources --- lua/lazyvim/plugins/coding.lua | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/lua/lazyvim/plugins/coding.lua b/lua/lazyvim/plugins/coding.lua index c6515802..c6571433 100644 --- a/lua/lazyvim/plugins/coding.lua +++ b/lua/lazyvim/plugins/coding.lua @@ -71,12 +71,13 @@ return { fallback() end, }), - sources = { - { name = "nvim_lsp", group_index = 1 }, - { name = "luasnip", group_index = 1 }, - { name = "buffer", group_index = 2 }, - { name = "path", group_index = 2 }, - }, + sources = cmp.config.sources({ + { name = "nvim_lsp" }, + { name = "luasnip" }, + { name = "path" }, + }, { + { name = "buffer" }, + }), formatting = { format = function(_, item) local icons = require("lazyvim.config").icons.kinds @@ -94,6 +95,13 @@ return { sorting = defaults.sorting, } end, + ---@param opts cmp.ConfigSchema + config = function(_, opts) + for _, source in ipairs(opts.sources) do + source.group_index = source.group_index or 1 + end + require("cmp").setup(opts) + end, }, -- auto pairs