From 650ce200f1362a892a4acf0f9659eb662c0f41e4 Mon Sep 17 00:00:00 2001 From: abeldekat Date: Fri, 3 Jan 2025 20:23:36 +0100 Subject: [PATCH] feat: an extra for mini.snippets. Review dpetka: use table.insert for opts.sources.default --- .../plugins/extras/coding/mini-snippets.lua | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/lua/lazyvim/plugins/extras/coding/mini-snippets.lua b/lua/lazyvim/plugins/extras/coding/mini-snippets.lua index b83e3f06..53f5cdd7 100644 --- a/lua/lazyvim/plugins/extras/coding/mini-snippets.lua +++ b/lua/lazyvim/plugins/extras/coding/mini-snippets.lua @@ -120,8 +120,9 @@ return { -- stylua: ignore -- Use mini.snippets to expand snippets from lsp: opts.snippet = { expand = function(args) expand(args) end } + + -- Show the snippets provided by mini.snippets in the completion popup: if snippets_in_cmp then - -- show the snippets provided by mini.snippets in the completion popup: table.insert(opts.sources, { name = "mini_snippets" }) end end, @@ -138,16 +139,14 @@ return { snippets_in_cmp = false snippet_select = snippet_select_for_blink + -- Remove builtin snippets source + opts.sources.default = vim.tbl_filter(function(source) + return source ~= "snippets" + end, opts.sources.default) + + -- Show the snippets provided by mini.snippets in the completion popup: if snippets_in_cmp then - opts.sources.default = { "mini_snippets" } - else - -- No snippets in completion, remove blink's builtin snippets - opts.sources.default = vim.tbl_filter(function(source) - if source == "snippets" then - return false - end - return true - end, opts.sources.default) + table.insert(opts.sources.default, "mini_snippets") end -- Blink defines the key.