From 5aa6252475a309415cc469e7d61658b6db169385 Mon Sep 17 00:00:00 2001 From: abeldekat Date: Mon, 30 Dec 2024 10:04:47 +0100 Subject: [PATCH] feat: an extra for mini.snippets. Issue a warning when user overrides jump_next or jump_previous. --- .../plugins/extras/coding/mini-snippets.lua | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/lua/lazyvim/plugins/extras/coding/mini-snippets.lua b/lua/lazyvim/plugins/extras/coding/mini-snippets.lua index 09646f8c..c686b558 100644 --- a/lua/lazyvim/plugins/extras/coding/mini-snippets.lua +++ b/lua/lazyvim/plugins/extras/coding/mini-snippets.lua @@ -7,11 +7,15 @@ This extra for mini.snippets activates the following: Note that there is no completion source. Other snippets(custom or from friendly-snippets) are handled by pressing in insert mode. -In default LazyVim, neither cmp nor blink define the default mappings used by mini.snippets -For now, pressing tab and shift-tab inside a snippet just inserts a tab +In default LazyVim, neither cmp nor blink define the default mappings used by mini.snippets: +- "" to expand +- "" to jump next (dynamically created when in snippet context) +- "" to jump previous (dynamically created when in snippet context) + +It's difficult to have jump_next or jump_previous working in all cases when mapped to ""/"". +For now, pressing tab and shift-tab inside a snippet just inserts a tab. +LazyVim will warn the user when jump_next of jump_previous are overriden. --- TODO: Find a way to incorporate user defined mappings including super-tab --- TODO: Find a way to more easily support lang_patterns for snippets.gen_loader.from_lang --]] local function expand(args) ---@diagnostic disable-next-line: undefined-global @@ -77,6 +81,16 @@ return { }, } end, + config = function(_, opts) + if opts.mappings and (opts.mappings.jump_next or opts.mappings.jump_previous) then + LazyVim["warn"]({ + "`mini.snippets`:", + "Don't override jump_next or jump_previous.", + "This does not work correctly in all cases.", + }, { title = "LazyVim" }) + end + require("mini.snippets").setup(opts) + end, }, -- nvim-cmp integration: Use mini.snippets to expand snippets from lsp