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

Is there any way to list regular expressions snippers (option r) #1512

Open
jambag opened this issue Dec 29, 2022 · 4 comments
Open

Is there any way to list regular expressions snippers (option r) #1512

jambag opened this issue Dec 29, 2022 · 4 comments

Comments

@jambag
Copy link

jambag commented Dec 29, 2022

I only want to know if there is a way to list snippets created with option r (pyton regular expression). For example:

snippet "be(gin)?( (\S+))?" "begin{} / end{}" br
\begin{${1:`!p
...

I've configured "g:UltiSnipsListSnippets", but this type of snippets don't appear on the list, and that's important for me to avoid remembering them.

Sorry I've not found the solution in docs and this list of issues.

Thank you very much


  • Operating System: Cygwin on WIndows 10
  • Vim Version: 8.2.4372
  • UltiSnips Version: 3.2 (latest)
  • Python inside Vim: 3.9.10
  • Docker repo/vimrc:
@smjonas
Copy link
Contributor

smjonas commented Jan 11, 2023

There is currently no built-in API to get this information. You have to write some hacky python code to achieve this.

For an example for Neovim, have a look here to see how we're doing this in cmp_nvim_ultisnips: https://github.com/quangnguyen30192/cmp-nvim-ultisnips/blob/main/autoload/cmp_nvim_ultisnips.vim.
This is where the Python code is called: https://github.com/quangnguyen30192/cmp-nvim-ultisnips/blob/f90ebb220306e39766ad0ec1f094e4e12bb2fdd4/lua/cmp_nvim_ultisnips/snippets.lua#L8

@SirVer
Copy link
Owner

SirVer commented Jan 12, 2023

@smjonas well, or submit a PR that introduces a relevant public API, right?

@jambag at the moment there is no easy way to get regex snippets. Background is that the default python regex engine cannot report "partial matches", hence we do not know in a context if a regex trigger is actually potentially valid or not.

@nonetallt
Copy link

nonetallt commented Jan 13, 2023

I was also just looking into this since I tried getting around the lack of aliases by using "or" regexes like "ns|namespace" but the regex snippets don't seem to play nice with other plugins (likely because they're not included in the snippets list).

I got the coc-snippets plugin to list my regex snippets but the string interpolation feature turned out problematic. More details in neoclide/coc-snippets#323.

Currently using coc-ultisnips, which works as one would expect from UltiSnips - regex snippets aren't listed.

@jambag
Copy link
Author

jambag commented Feb 9, 2023

Thank you very much.

I hadn't thought about the complexity of partial matches, perhaps because the regexp I had in mind were very simple. I see now.

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

No branches or pull requests

4 participants