-
-
Notifications
You must be signed in to change notification settings - Fork 245
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
Improved syntax file and ftplugin for SnipMate snippets. #1211
Conversation
Hey, I didn't have time to look at anything until now, and now it's too late here to properly test this, I just already wanted to say Thank You for the clean PR, I really appreciate that you went into some detail on the changes because I've not written a syntax-file in my life :D (+1 for good screenshots, very nice 👌) |
Hello again, had some time to look over the changes, AFAICT everything works just as you say 👌 |
Was a bit of a hassle (syntax/ftplugin files didn't load automatically for some reason) but here we are. |
Hi, Sorry for the late reply. I've been migrating from Vim to NeoVim, which involved a lot of learning and setup. I committed to moving all my plugins to lazy.nvim this past week, and my editor was unusable for a few days. Almost everything is working well with my new NeoVim configuration now. I'm glad the changes are working as expected. Unfortunately, I still don't know anything about the test directory and how it works. I tried running make test after installing many packages on Debian, but I couldn't figure out how it was supposed to help me. So, I reverted to the manual approach and modified the syntax and ftplugin files directly. Then, I opened tests/data/syntaxtest.snippets in NeoVim, and it worked fine. So I think it's ready for merge and I don't have any other ideas to make it better at the moment. I'm still new to NeoVim, i'm sorry :)) |
Oh, no worries about replying a few days later :P |
Hi, I would like to know if folding could be optional? I personally don't like files folded when opening them. Thanks! |
I think you can adjust |
Hi again :))
I've made a few changes to improve the syntax highlighting and folding behavior for code snippets.
I noticed that both the ftplugin and syntax files in vsnip and luasnip are copied from vim-snipmate, and the issue is that they both have syntax errors from the start. I had asked a question about this on Reddit (see link below).
Link to Reddit question
List of changes:
Changes to syntax file:
Removed the syntax for the "version" keyword. This is related to vim-snipmate, which has two different versions of the snippet engine.
Fixed a syntax error in the snipKeyword definition.
In regular expressions, there are two types of groups: capturing groups and non-capturing groups.
In Vim, since regular expressions are in magic mode by default, groups must be escaped with a backslash.
For better syntax highlighting, it's also recommended to use non-capturing groups because they don't store unnecessary substrings and are faster.
The capturing group syntax is:
And the non-capturing group syntax is:
It's also important to note that the OR operator in Vim's magic mode regular expressions is:
We also don't need
me=s+8
. This prevents the "autosnippet" keyword from being highlighted correctly. Without it, everything works fine, so there's no need to write extra code. :)See the screenshot for a visual representation of the changes.
Changes to ftplugin file:
I personally use spaces instead of tabs, and I think it's better to leave it to the user's default settings. So, I removed the part about using tabs.
I slightly improved the folding functionality. It now works for both files written with hard tabs and soft tabs.
Also, the words "expand," "priority," and comments are not folded.
I wanted to submit these changes to vsnip in the past, but I needed more time to learn regex in Vim. By the time I was ready, I was using luasnip, so I'm sending them to you instead. :))
A few notes:
I hope this is helpful. Thank you! :))
Before the changes:
After the changes in the syntax file (pay attention to the problem with the word autosnippet, Because of this piece of code me=s+8)
And examples after complete changes