mirror of
https://github.com/LazyVim/LazyVim.git
synced 2026-07-25 14:01:06 +00:00
feat: an extra for mini.snippets. Issue a warning when user overrides jump_next or jump_previous.
This commit is contained in:
parent
5b057e92eb
commit
5aa6252475
1 changed files with 18 additions and 4 deletions
|
|
@ -7,11 +7,15 @@ This extra for mini.snippets activates the following:
|
||||||
Note that there is no completion source.
|
Note that there is no completion source.
|
||||||
Other snippets(custom or from friendly-snippets) are handled by pressing <c-j> in insert mode.
|
Other snippets(custom or from friendly-snippets) are handled by pressing <c-j> in insert mode.
|
||||||
|
|
||||||
In default LazyVim, neither cmp nor blink define the default mappings used by mini.snippets
|
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
|
- "<c-j>" to expand
|
||||||
|
- "<c-l>" to jump next (dynamically created when in snippet context)
|
||||||
|
- "<c-h>" 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 "<tab>"/"<s-tab>".
|
||||||
|
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)
|
local function expand(args)
|
||||||
---@diagnostic disable-next-line: undefined-global
|
---@diagnostic disable-next-line: undefined-global
|
||||||
|
|
@ -77,6 +81,16 @@ return {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
end,
|
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
|
-- nvim-cmp integration: Use mini.snippets to expand snippets from lsp
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue