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

Custom mapping to escape snippet expansion #129

Open
karamellpelle opened this issue Feb 25, 2024 · 2 comments
Open

Custom mapping to escape snippet expansion #129

karamellpelle opened this issue Feb 25, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@karamellpelle
Copy link

karamellpelle commented Feb 25, 2024

Problem Statement

I'm so used to press <Esc> after typing, so I often jump out of the snippet expansion before it is populated.

Ideas or possible solutions

Is it possible to add a custom mapping to escape from snippet expansion? So if this setting is defined, the default <Esc> is ignored, and you have to use your own mapping to escape.

Also, it would be nice to have a settings that forces you to press the escape mapping so the expansion does not quit automatically when all items are populated.

Alternatives you have considered

No response

@karamellpelle karamellpelle added the enhancement New feature or request label Feb 25, 2024
@dcampos
Copy link
Owner

dcampos commented Mar 27, 2024

Hey! Please let me know if I'm missing anything, but pressing <Esc> generally doesn't finish snippet expansion; it enters normal mode and, if you don't have a normal mode mapping for jumping, you'll need to go back to insert mode to be able to jump around.

Maybe you could set up an autocmd for remapping <Esc> to something else while a snippet is active and remove this mapping once you're done with the snippet (:h snippy-autocmds).

Also, it would be nice to have a settings that forces you to press the escape mapping so the expansion does not quit automatically when all items are populated.

Sounds useful!

@karamellpelle
Copy link
Author

karamellpelle commented Mar 28, 2024

Looks like pressing i lets you jump back into snippet expansion, unless you move in normal mode. Thanks for this information!

If I can remap <Esc> into for example <Nop> only during snippet expansion, then I can prevent unintentionally jump out of snippet expansion so often. Nice to have a setting for such key, though. <Esc> should then be the default setting.


I used your nice nvim-snippy to write a plugin for file templates: nvim-skeletty. I was so tired of always copy, paste and substitute words from the same file template whenever I needed a new file in my project. I think it works pretty well at the moment, but it hasn't been tested by others AFAIK. It also lets you preview each file template if you have nvim-telescope installed, automatically. If you want to contribute to this plugin, you are welcome :)

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

No branches or pull requests

2 participants