-
Notifications
You must be signed in to change notification settings - Fork 19
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
Feat: add support for custom context snippets #72
Feat: add support for custom context snippets #72
Conversation
54801c2
to
c4e5f45
Compare
bbf066c
to
bca1438
Compare
@quangnguyen30192 @jasonkena could one of you quickly test this branch? I tested it better myself this time and it seems to be working fine but I just want to be sure before merging :) |
How do I test it 😅 could you provide me the steps? |
Yes sure 😅 One way to test it is to install Or you could simply create the following snippet file (e.g. to test it for a Lua file global !p
def math():
return vim.eval('vimtex#syntax#in_mathzone()') == '1'
endglobal
context "math()"
snippet frac "Fraction"
\\frac{$1}{$2}$0
endsnippet |
Thanks, tested, LGTM |
@smjonas thank you for your work! Unfortunately, the expansions also work outside the math contexts, the "iA" (auto-trigger) flags on the snippets do not work, and complex pattern matching fails e.g.
|
Thank you for the feedback, I will check it! Edit: @jasonkena I could not reproduce your first point, the snippet you provided won't expand in non-math contexts for me. I'll see if I can do something about your second point - by not working you simply mean the snippet is not shown, right? (at least, that's how it behaves for me; this is also the case on the latest commit on the main branch). Or is it now not expanded at all when typing So I think this could be improved in a follow-up PR, I'd suggest to merge this first because it does not seem to break any existing functionality. Of course, let me know if that's not the case! |
@smjonas hmm... it's still broken for me. Could you please send a minimal vimrc/luarc? |
For example the snippet
frac
will now be shown by cmp when the user is in math mode in a
.tex
file.