-
-
Notifications
You must be signed in to change notification settings - Fork 245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
allow undoing autoexpand #830
Comments
This is similar to #797, a description for achieving this via api is in there, but I haven't considered just using undo for this. Is it possible to register a new undo-point (?) via lua? |
I can confirm it works with this hack local auto_expand = require("luasnip").expand_auto
require("luasnip").expand_auto = function(...)
vim.o.undolevels = vim.o.undolevels
auto_expand(...)
end |
Ahh okay, thank you! |
I think in the long run an api would be the better solution local auto_expand = require("luasnip").expand_auto
require("luasnip").expand_auto = function(...)
vim.o.undolevels = vim.o.undolevels
auto_expand(...)
end this isn't a nice solution though because it sets new undo everytime the function is called |
Slightly better: set the new undo-point in (/around?) |
I tried both
however, adding undo in
Did I set it wrong? or is there a better alternative? |
also, I'm as well looking forward for an api to came out, thank you L3MON4D3 :D |
local snip_expand = require("luasnip").snip_expand
require("luasnip").snip_expand = function(...)
vim.o.ul = vim.o.ul
snip_expand(...)
end works for me |
strange, just doesn't work for me. Are you using an auto-trigger or expand by enter? |
autoexpand snippets |
I'm also using autoexpand snippets. Then there might be something wrong in my configs somewhere. |
you should be able to just do |
oh yes, and that worked, but it's a bit not that automatic. |
well you could just map that to something |
How do you actually implement this solution? like do i just plop this into an init.lua? |
yes |
Hi, @@ -363,7 +363,7 @@ local function expand_auto()
},
to = cursor,
}
- snip = snip_expand(snip, {
+ snip = ls.snip_expand(snip, {
expand_params = expand_params,
-- clear trigger-text.
clear_region = clear_region, to |
it should somehow be possible to undo autoexpand if a snippet autoexpanded when it shouldn't have
I see two options for this
either start a new undo sequence so you can just
<c-o>u
from insert mode or provide an api to do it which can be mapped toThe text was updated successfully, but these errors were encountered: