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

Expand snippets if only partial prefix of the trigger word is typed #1207

Open
danijar opened this issue Apr 13, 2020 · 4 comments
Open

Expand snippets if only partial prefix of the trigger word is typed #1207

danijar opened this issue Apr 13, 2020 · 4 comments
Labels
good first issue triaged

Comments

@danijar
Copy link

@danijar danijar commented Apr 13, 2020

I would like to write snippets that can be expanded after typing only a part of the trigger word. For example, i, im, imp, impo, impor should all expand to import when followed by the trigger key, e.g. Tab. This is helpful because one may think of a snippet after having already typed a couple of characters of a code construct. At the moment, this is possible through somewhat complicated regexes, making it hard to define such snippets. Is this supported in an easier way? If not, would it make sense to add a snippet option for this?

@danijar danijar changed the title How to insert snippets by only typing partial prefix of the trigger word? Typing only partial prefix of the trigger word? Apr 13, 2020
@danijar
Copy link
Author

@danijar danijar commented Apr 13, 2020

Nevermind, I found #268. You're mentioning completers that are better suited for this use case. Which ones were you thinking of? By the way, I think it would be perfectly fine if this didn't work for regex triggers if it were added as a feature.

@tbrazel
Copy link

@tbrazel tbrazel commented Apr 15, 2020

As you noted, the regex for this would be rough: i(?:m(?:p(?:o(?:r(?:t?)?)?))?)? Personally I would also love the feature that you're proposing and that was proposed in #268.

One popular completer is deoplete, and many people swear by it.

@danijar
Copy link
Author

@danijar danijar commented Apr 15, 2020

Thanks for sharing the regex. If this worked it should be really easy to add this feature as a snippet option to UltiSnips.

I'm using droplete but so far it seems to fill quite a different use case than triggering snippets that may include anchors for the cursor to jump to etc.

@SirVer
Copy link
Owner

@SirVer SirVer commented Feb 15, 2021

Yes, this would not be a hard feature to add. I came around to it as maybe being a good idea to implement and would love to see a patch for it.

@SirVer SirVer added good first issue triaged labels Feb 15, 2021
@SirVer SirVer changed the title Typing only partial prefix of the trigger word? Expand snippets if only partial prefix of the trigger word is typed Feb 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue triaged
Projects
None yet
Development

No branches or pull requests

3 participants