Skip to content
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

question/bug/feature: set undo break before trigering the snippet #959

Closed
ghost opened this issue Jul 18, 2023 · 2 comments
Closed

question/bug/feature: set undo break before trigering the snippet #959

ghost opened this issue Jul 18, 2023 · 2 comments

Comments

@ghost
Copy link

ghost commented Jul 18, 2023

First of all thank everybody for such a great plugin!

It happens relatively often that I would like to undo the triggered snippet. It would be nice to add the option to set an undo break before the snippet is triggered like you would do with i_CTRL_G u.

What I would like is smth like this:

s({ trig = "trig", snippetType = "autosnippet" }, t [[some other text]),

Example:
Here is trig -> Here is some other text
After pressing undo
Here is some other text -> Here is trig

What I tried so far is to use feedkeys but without success. What I tried is

local function tt(text)
return f(function()
vim.api.nvim_input("u")
return text
end)
end

s({ trig = "trig", snippetType = "autosnippet" }, tt[[some other text]),

It works with snippetType = "snippet"

@ghost ghost changed the title Question/bug: set undo break before trigering the snippet question/bug/feature: set undo break before trigering the snippet Jul 18, 2023
@ghost
Copy link
Author

ghost commented Jul 18, 2023

Did not notice that <c-g> is formated by markdown/github. The tt function in the text above should have been

local function tt(text)
  return f(function()
    vim.api.nvim_input("<C-G>u")
    return text 
  end)
end

@L3MON4D3
Copy link
Owner

#830 is exactly this afaict, I'll close in favor of that issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant