hare.vim

[vim] Hare vim plugin
git clone https://git.torresjrjr.com/hare.vim.git
Log | Files | Refs | README | LICENSE

commit aeda208dbf95a85aad5d5e677f2d8479417e04cd
parent b15efa7bda937c258c90367898fad31364b9b6fc
Author: Amelia Clarke <me@rsaihe.dev>
Date:   Mon, 22 Aug 2022 19:45:47 -0700

syntax: organize file into sections

This commit improves the organization of the syntax file by dividing it
into sections. Folding of each section can be enabled with
:set foldmethod=marker.

Signed-off-by: Amelia Clarke <me@rsaihe.dev>

Diffstat:
Msyntax/hare.vim | 61++++++++++++++++++++++++++++++++++++++-----------------------
1 file changed, 38 insertions(+), 23 deletions(-)

diff --git a/syntax/hare.vim b/syntax/hare.vim @@ -1,12 +1,16 @@ +" PRELUDE {{{1 " Vim syntax file " Language: Hare if exists("b:current_syntax") finish endif +let b:current_syntax = "hare" +" SYNTAX {{{1 syn case match +" KEYWORDS {{{2 syn keyword hareConditional if else match switch syn keyword hareKeyword break continue return yield syn keyword hareKeyword defer @@ -22,17 +26,29 @@ syn keyword hareTypedef type " C ABI. syn keyword hareKeyword vastart vaarg vaend +" BUILTINS {{{2 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 "\.\.\." "\.\." -syn match hareErrorAssertion "\v(^([^/]|//@!)*\)\_s*)@<=!\=@!" -syn match hareQuestionMark "?" +" TYPES {{{2 +syn keyword hareType bool +syn keyword hareType char str +syn keyword hareType f32 f64 +syn keyword hareType u8 u16 u32 u64 i8 i16 i32 i64 +syn keyword hareType uint int +syn keyword hareType rune +syn keyword hareType uintptr +syn keyword hareType void + +" C ABI. +syn keyword hareType valist + +" LITERALS {{{2 +syn keyword hareBoolean true false +syn keyword hareNull null " Number literals. syn match hareNumber "\v(\.@1<!|\.\.)\zs<\d+([Ee][+-]?\d+)?(z|[iu](8|16|32|64)?)?>" display @@ -53,28 +69,29 @@ 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 +" MISCELLANEOUS {{{2 +syn keyword hareTodo FIXME TODO XXX contained + +" Attributes. +syn match hareAttribute "@[a-z]*" + +" Comments. +syn region hareComment start="//" end="$" contains=hareTodo,@Spell + " 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 +" Trailing whitespace. +syn match hareSpaceError "\v\s+$" display excludenl +syn match hareSpaceError "\v\zs +\ze\t" display -syn keyword hareTodo contained TODO FIXME XXX -syn region hareComment start="//" end="$" contains=hareTodo,@Spell - -syn keyword hareType u8 u16 u32 u64 i8 i16 i32 i64 -syn keyword hareType uint int -syn keyword hareType uintptr -syn keyword hareType f32 f64 -syn keyword hareType bool -syn keyword hareType char str -syn keyword hareType void -syn keyword hareType rune -syn keyword hareType valist -syn keyword hareNull null -syn keyword hareBoolean true false +syn match harePreProc "^use .*;" +syn match hareOperator "\.\.\." "\.\." +syn match hareErrorAssertion "\v(^([^/]|//@!)*\)\_s*)@<=!\=@!" +syn match hareQuestionMark "?" +" DEFAULT HIGHLIGHTING {{{1 hi def link hareAttribute Keyword hi def link hareBoolean Boolean hi def link hareBuiltin Function @@ -105,6 +122,4 @@ autocmd InsertLeave * hi link hareSpaceError Error hi def hareErrorAssertion ctermfg=red cterm=bold guifg=red gui=bold -let b:current_syntax = "hare" - " vim: tabstop=8 shiftwidth=2 expandtab