feat: an extra for mini.snippets. Review folke: document mappings.stop = esc

This commit is contained in:
abeldekat 2025-01-11 17:12:07 +01:00
parent 1bd6356975
commit ba6364a6ca

View file

@ -9,21 +9,15 @@ if lazyvim_docs then
-- Also, those completions do not appear when using luasnip or native snippets -- Also, those completions do not appear when using luasnip or native snippets
-- --
-- Set to `false` to enable completion suggestions directly after inserting a snippet -- Set to `false` to enable completion suggestions directly after inserting a snippet
vim.g.lazyvim_mini_snippets_expand_insert_override = true vim.g.lazyvim_mini_snippets_override_expand_insert = true
-- NOTE: Please also read: -- NOTE: Please also read:
-- https://github.com/echasnovski/mini.nvim/blob/main/readmes/mini-snippets.md#expand -- https://github.com/echasnovski/mini.nvim/blob/main/readmes/mini-snippets.md#expand
-- :h MiniSnippets-session -- :h MiniSnippets-session
end
local include_in_completion = vim.g.lazyvim_mini_snippets_in_completion == nil -- Example override for your own config:
or vim.g.lazyvim_mini_snippets_in_completion --[[
local override_expand_insert = vim.g.lazyvim_mini_snippets_expand_insert_override == nil return {
or vim.g.lazyvim_mini_snippets_expand_insert_override
--[[
Example override for your own config:
return {
{ {
"echasnovski/mini.snippets", "echasnovski/mini.snippets",
opts = function(_, opts) opts = function(_, opts)
@ -45,8 +39,14 @@ return {
} }
end, end,
}, },
} }
--]] --]]
end
local include_in_completion = vim.g.lazyvim_mini_snippets_in_completion == nil
or vim.g.lazyvim_mini_snippets_in_completion
local override_expand_insert = vim.g.lazyvim_mini_snippets_override_expand_insert == nil
or vim.g.lazyvim_mini_snippets_override_expand_insert
local function expand_from_lsp(snippet) local function expand_from_lsp(snippet)
local insert = MiniSnippets.config.expand.insert or MiniSnippets.default_insert local insert = MiniSnippets.config.expand.insert or MiniSnippets.default_insert
@ -90,6 +90,13 @@ return {
local mini_snippets = require("mini.snippets") local mini_snippets = require("mini.snippets")
return { return {
snippets = { mini_snippets.gen_loader.from_lang() }, snippets = { mini_snippets.gen_loader.from_lang() },
-- Following the behavior of vim.snippets,
-- the intended usage of <esc> is to be able to temporarily exit into normal mode for quick edits.
--
-- If you'd rather stop the snippet on <esc>, activate the line below in your own config:
-- mappings = { stop = "<esc>" }, -- <c-c> by default, see :h MiniSnippets-session
expand = { expand = {
select = function(snippets, insert) select = function(snippets, insert)
-- Close completion window on snippet select - vim.ui.select -- Close completion window on snippet select - vim.ui.select