-
Notifications
You must be signed in to change notification settings - Fork 59
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
Add highlight group for ! and ? operators #79
Comments
This is (partially) addressed in #80. |
For
I've worked with rules like this before, and it's quite straight-forward to get things working correctly. For a syntax as sparse as Zig's, it may be even easier. Here's a screenshot of my first update to the rules (based on the changes in #80): The syntax rules require knowing the sequence of tokens to test. In this case, Like so: " XXX Other zigType rules listed elsewhere.
" TODO Handle explicit error set type before the !.
syn match zigType "[!]\?[A-Za-z_][A-Za-z0-9_]*" contained
" FUNCTIONS {{{2
syn keyword zigKeyword fn skipwhite nextgroup=zigFunctionName
syn match zigFunctionName "[A-Za-z_][A-Za-z0-9_]*" contained skipwhite nextgroup=zigFunctionParams
syn region zigFunctionParams start="(" end=")" contained contains=TOP skipwhite nextgroup=zigType The secondary, contextual rules are
Bonus for this approach: free highlighting of smaller syntax elements, like function names in function declarations. If you're interested in doing something like this and want some help writing/testing/debugging, let me know. 😊 |
There should be a special highlight group for the error set operator (!) and the optional operator (?). I propose the names
zigErrorSet
andzigOptional
for these highlight groups.Ideally it would be possible to have
zigErrorSet
not match the logical NOT operator (!), but I am not sure how such a thing might be implemented.zigErrorSet
andzigOptional
should be linked to the (currently unused)zigSpecial
highlight group.Additionally, I feel it would also make sense to create a new highlight group
zigDeref
for the pointer dereference operator, which could perhaps also be linked tozigSpecial
.? and ! in particular are quite important to pay attention to, so I feel it makes sense to allow them to be specially highlighted to make them more obvious when reading code.
The text was updated successfully, but these errors were encountered: