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

Ultisnips snippet with "Regular expression" snippet options are not displayed in PUM, but work #17

Closed
promisedlandt opened this issue Mar 12, 2019 · 4 comments

Comments

@promisedlandt
Copy link

UltiSnips snippets with "regular expression (r)" option are not displayed in the PUM. They are expanded 100% correctly (including jumping to placeholders).

Example snippet:

 snippet "(\S+)\.det" "<elements>.detect do |<element>| <block> end" r                                                              `!p snip.rv=match.group(1)`.detect do |${1}|
  $0
end
endsnippet

If I expand this in an empty line nothing happens, which is correct.
If I expand this after e.g. [], I can get items in the PUM from other sources, like buffer, but not from snippet source. But, when expanding the item, it works fine.

Seems like not high priority bug because I can work with it fine, it's just display issue.

From UltiSnips docs:

r Regular expression - With this option, the tab trigger is expected to
be a python regular expression. The snippet is expanded if the recently
typed characters match the regular expression. Note: The regular
expression MUST be quoted (or surrounded with another character) like a
multi-word tab trigger (see above) whether it has spaces or not. A
resulting match is passed to any python code blocks in the snippet
definition as the local variable "match".

@chemzqm
Copy link
Member

chemzqm commented Mar 13, 2019

Because for most of regex patterns, it's not possible to know what should be inserted with complete item, so can't show them in pum.

@promisedlandt
Copy link
Author

Sure, that makes sense. Also, no problem for me :)

@danihodovic
Copy link

danihodovic commented Jan 15, 2020

Because for most of regex patterns, it's not possible to know what should be inserted with complete item, so can't show them in pum.

@chemzqm Is it possible to enable this behavior anyway? I have a bunch of regex snippets from Ultisnips and I want them to show in the completion menu. If they're not shown I forget they exist because I don't manually trigger completion.

@nomasprime
Copy link

Just ran into this. Doubt anyone can remember all their snippets so pretty much makes regex option unusable.

Going to stick with UltiSnips because the short description's helpful but will start refactoring any that use regex.

emilford added a commit to emilford/dotfiles that referenced this issue Apr 3, 2021
<c-y> is used to select and expand snippets that appear in CoC's preview
pop up. There's a [known
limitation](neoclide/coc-snippets#17) that
snippets definitions that use regex will not show up in the preview.

These regex-based snippets are still handy, however. For consistency,
also use <c-y> to expand them.
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

4 participants