! is highlighted bold red when it appears immediately after a closing
parentheses that wasn't part of a comment, and is not immediately
followed by an equals sign.
Note that this only works when ! comes after a function call, as it
almost always does. Handling all edge cases where ! is used after a
non-call expression is, if not impossible, extremely impractical without
the use of semantic analysis.
Signed-off-by: Sebastian <sebastian@sebsite.pw>
---
Since v1: ! is only highlighted following a function call. See the
commit message for reasoning.
syntax/hare.vim | 3 +++
1 file changed, 3 insertions(+)
diff --git a/syntax/hare.vim b/syntax/hare.vim
index b3eb750..362f4b7 100644
--- a/syntax/hare.vim
+++ b/syntax/hare.vim
@@ -18,6 +18,7 @@ syn match hareBuiltin "\v<size>((\_s|//.*\n)*\()@="
syn match harePreProc "^use .*;"
syn match harePreProc "@[a-z]*"
syn match hareOperator "\.\.\." "\.\."
+syn match hareErrorAssertion "\v(^([^/]|//@!)*\)\_s*)@<=!\=@!"
syn region hareString start=+\z(["']\)+ end=+\z1+ skip=+\\\\\|\\\z1+
syn region hareString start=+`+ end=+`+
@@ -79,4 +80,6 @@ hi def link hareSpaceError Error
autocmd InsertEnter * hi link hareSpaceError NONE
autocmd InsertLeave * hi link hareSpaceError Error
+hi hareErrorAssertion ctermfg=red cterm=bold guifg=red gui=bold
+
" vim: tabstop=8 shiftwidth=2 expandtab
--
2.36.1
I'm not sure hardcoding the highlighting is a good idea, that should be
left to color schemes. It's probably better to just link it to some
predefined highlighting group (or define a new highlighting group) so
that the actual highlighting is done based on people's color scheme of
choice.