I am using ultisnips with Gilles Castel's subscript snippet along with a snippet I found on SE to create matrices in latex rather quickly. Unfortunately, I can't use the matrices snippet because it keeps triggering the subscript snippet and I'm not sure how to make the two work together. The snippet for matrices is defined as follows, (there is a separate python function it calls which can be found here)
priority 1100
pre_expand "create_matrix(snip)"
snippet "(small|[bBpvV])?mat(rix)?(\d+)x(\d+)" "Generate (small|[bBpvV])?matrix of *rows* by *columns*" br
endsnippet
The snippets for the subscripting are defined as follows,
context "math()"
snippet '([A-Za-z])(\d)' "auto subscript" wrA
`!p snip.rv = match.group(1)`_`!p snip.rv = match.group(2)`
endsnippet
context "math()"
snippet '([A-Za-z])_(\d\d)' "auto subscript2" wrA
`!p snip.rv = match.group(1)`_{`!p snip.rv = match.group(2)`}
endsnippet
Unfortunately, whenever I try to use the first snippet, e.g. by typing
bmat3x3<TAB>
The subscript snippet triggers and instead outputs
bmat3x_3
Is there any way I can make it so that the subscript snippet does not trigger in this case? I was thinking perhaps there's a way to check if the current word contains "bmat". I'm sorry I'm not familiar with regular expressions as I feel like if I was I could write some sort of if statement evaluating the word to only trigger when the word did not contain bmat.
Thanks.
([A-Za-z]*)(?<![bBpvV]mat)(\d)
is allowed but not([A-Za-z]*)(?<!(small|[bBpvV])?mat(rix))(\d)
. This means you have to write it differently, e.g.([A-Za-z]*)(?<![bBpvV]mat)(?<![^A-Za-z]mat)(\d)
. I would say this becomes unmanageable. If someone else has a better idea, I am happy to see it.bmat3
triggers only the 'auto-subscript' snippet and not the matrix snippet. Therefore, I do not think that changing the priority helps.