~sircmpwn/hare-dev

hare.vim: Highlight error assertion operator bold red v2 APPLIED

Sebastian: 1
 Highlight error assertion operator bold red

 1 files changed, 3 insertions(+), 0 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~sircmpwn/hare-dev/patches/33242/mbox | git am -3
Learn more about email & git

[PATCH hare.vim v2] Highlight error assertion operator bold red Export this patch

! 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.
I know it's not perfect, but I still think it's an improvement. We'll
see how the edge cases fall out in practice. Thanks!

To git@git.sr.ht:~sircmpwn/hare.vim
   adcf043..5c758cd  master -> master