From 96651972b0c1094697ec4cb9643b4c36903f3815 Mon Sep 17 00:00:00 2001 From: arne314 <73391160+arne314@users.noreply.github.com> Date: Wed, 11 Jun 2025 17:00:35 +0200 Subject: [PATCH] feat(snip): add undo breakpoints --- lua/typstar/config.lua | 1 + lua/typstar/engine.lua | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/lua/typstar/config.lua b/lua/typstar/config.lua index b7b4b19..0a9b338 100644 --- a/lua/typstar/config.lua +++ b/lua/typstar/config.lua @@ -18,6 +18,7 @@ local default_config = { }, snippets = { enable = true, + add_undo_breakpoints = true, modules = { -- enable modules from ./snippets 'letters', 'math', diff --git a/lua/typstar/engine.lua b/lua/typstar/engine.lua index 2cd8c33..4757b13 100644 --- a/lua/typstar/engine.lua +++ b/lua/typstar/engine.lua @@ -167,6 +167,15 @@ function M.setup() end end luasnip.add_snippets('typst', autosnippets) + + if cfg.add_undo_breakpoints then + vim.api.nvim_create_autocmd('User', { + pattern = 'LuasnipPreExpand', + callback = function() + vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes('u', true, false, true), 'n', false) + end, + }) + end end end