commit b15efa7bda937c258c90367898fad31364b9b6fc
parent 796ad385307656985d16c7377b441807f4735fda
Author: Amelia Clarke <me@rsaihe.dev>
Date: Mon, 22 Aug 2022 19:45:46 -0700
syntax: improve highlighting for size keyword
This commit adds more advanced detection of the size keyword and now
differentiates the builtin from the type regardless of empty lines or
comments between the keyword and an opening parenthesis.
The other builtins have been slightly reordered as well.
Signed-off-by: Amelia Clarke <me@rsaihe.dev>
Diffstat:
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/syntax/hare.vim b/syntax/hare.vim
@@ -22,9 +22,12 @@ syn keyword hareTypedef type
" C ABI.
syn keyword hareKeyword vastart vaarg vaend
-syn keyword hareBuiltin len offset free alloc assert append abort delete insert
-syn match hareType "\v<size>((\_s|//.*\n)*\()@!"
-syn match hareBuiltin "\v<size>((\_s|//.*\n)*\()@="
+syn keyword hareBuiltin abort
+syn keyword hareBuiltin alloc free
+syn keyword hareBuiltin append delete insert
+syn keyword hareBuiltin assert
+syn keyword hareBuiltin len offset
+
syn match harePreProc "^use .*;"
syn match hareAttribute "@[a-z]*"
syn match hareOperator "\.\.\." "\.\."
@@ -50,6 +53,10 @@ syn region hareRune start="'" end="'\|$" skip="\\'" contains=hareEscape display
syn region hareString start=+"+ end=+"\|$+ skip=+\\"+ contains=hareEscape,hareFormat display extend
syn region hareString start="`" end="`\|$" contains=hareFormat display
+" The size keyword can be either a builtin or a type.
+syn match hareBuiltin "\v<size>\ze(\_s*//.*\_$)*\_s*\(" contains=hareComment
+syn match hareType "\v<size>((\_s*//.*\_$)*\_s*\()@!" contains=hareComment
+
syn match hareSpaceError display excludenl "\v\s+$"
syn match hareSpaceError display "\v +\t"me=e-1