| 
									
										
										
										
											2024-05-24 08:05:00 +02:00
										 |  |  | " Vim syntax file. | 
					
						
							|  |  |  | " Language:    Hare | 
					
						
							|  |  |  | " Maintainer:  Amelia Clarke <selene@perilune.dev> | 
					
						
							|  |  |  | " Last Change: 2024-05-10 | 
					
						
							|  |  |  | " Upstream:    https://git.sr.ht/~sircmpwn/hare.vim | 
					
						
							| 
									
										
										
										
											2022-09-27 17:30:34 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-24 08:05:00 +02:00
										 |  |  | if exists('b:current_syntax') | 
					
						
							| 
									
										
										
										
											2022-09-27 17:30:34 +01:00
										 |  |  |   finish | 
					
						
							|  |  |  | endif | 
					
						
							| 
									
										
										
										
											2024-05-24 08:05:00 +02:00
										 |  |  | syn include @haredoc syntax/haredoc.vim | 
					
						
							|  |  |  | let b:current_syntax = 'hare' | 
					
						
							| 
									
										
										
										
											2022-09-27 17:30:34 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-24 08:05:00 +02:00
										 |  |  | " Syntax {{{1 | 
					
						
							| 
									
										
										
										
											2022-09-27 17:30:34 +01:00
										 |  |  | syn case match | 
					
						
							| 
									
										
										
										
											2024-05-24 08:05:00 +02:00
										 |  |  | syn iskeyword @,48-57,@-@,_ | 
					
						
							| 
									
										
										
										
											2022-09-27 17:30:34 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-24 08:05:00 +02:00
										 |  |  | " Keywords {{{2 | 
					
						
							|  |  |  | syn keyword hareConditional else if match switch | 
					
						
							|  |  |  | syn keyword hareDefine def | 
					
						
							|  |  |  | syn keyword hareInclude use | 
					
						
							| 
									
										
										
										
											2022-09-27 17:30:34 +01:00
										 |  |  | syn keyword hareKeyword break continue return yield | 
					
						
							| 
									
										
										
										
											2024-05-24 08:05:00 +02:00
										 |  |  | syn keyword hareKeyword case | 
					
						
							|  |  |  | syn keyword hareKeyword const let | 
					
						
							| 
									
										
										
										
											2022-09-27 17:30:34 +01:00
										 |  |  | syn keyword hareKeyword defer | 
					
						
							| 
									
										
										
										
											2024-05-24 08:05:00 +02:00
										 |  |  | syn keyword hareKeyword export static | 
					
						
							| 
									
										
										
										
											2022-09-27 17:30:34 +01:00
										 |  |  | syn keyword hareKeyword fn | 
					
						
							|  |  |  | syn keyword hareOperator as is | 
					
						
							|  |  |  | syn keyword hareRepeat for | 
					
						
							|  |  |  | syn keyword hareTypedef type | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-24 08:05:00 +02:00
										 |  |  | " Attributes. | 
					
						
							|  |  |  | syn keyword hareAttribute @fini @init @test | 
					
						
							|  |  |  | syn keyword hareAttribute @offset @packed | 
					
						
							|  |  |  | syn keyword hareAttribute @symbol | 
					
						
							|  |  |  | syn keyword hareAttribute @threadlocal | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | " Builtins. | 
					
						
							|  |  |  | syn keyword hareBuiltin abort assert | 
					
						
							|  |  |  | syn keyword hareBuiltin align len offset | 
					
						
							| 
									
										
										
										
											2022-09-27 17:30:34 +01:00
										 |  |  | syn keyword hareBuiltin alloc free | 
					
						
							|  |  |  | syn keyword hareBuiltin append delete insert | 
					
						
							| 
									
										
										
										
											2024-05-24 08:05:00 +02:00
										 |  |  | syn keyword hareBuiltin vaarg vaend vastart | 
					
						
							| 
									
										
										
										
											2022-09-27 17:30:34 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-24 08:05:00 +02:00
										 |  |  | " Types {{{2 | 
					
						
							| 
									
										
										
										
											2022-09-27 17:30:34 +01:00
										 |  |  | syn keyword hareType bool | 
					
						
							| 
									
										
										
										
											2024-05-24 08:05:00 +02:00
										 |  |  | syn keyword hareType done | 
					
						
							| 
									
										
										
										
											2022-09-27 17:30:34 +01:00
										 |  |  | syn keyword hareType f32 f64 | 
					
						
							| 
									
										
										
										
											2024-05-24 08:05:00 +02:00
										 |  |  | syn keyword hareType i8 i16 i32 i64 int | 
					
						
							|  |  |  | syn keyword hareType never | 
					
						
							|  |  |  | syn keyword hareType opaque | 
					
						
							|  |  |  | syn keyword hareType rune str | 
					
						
							|  |  |  | syn keyword hareType u8 u16 u32 u64 uint | 
					
						
							| 
									
										
										
										
											2022-09-27 17:30:34 +01:00
										 |  |  | syn keyword hareType uintptr | 
					
						
							| 
									
										
										
										
											2024-05-24 08:05:00 +02:00
										 |  |  | syn keyword hareType valist | 
					
						
							| 
									
										
										
										
											2022-09-27 17:30:34 +01:00
										 |  |  | syn keyword hareType void | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-24 08:05:00 +02:00
										 |  |  | " Other types. | 
					
						
							|  |  |  | syn keyword hareStorageClass nullable | 
					
						
							|  |  |  | syn keyword hareStructure enum struct union | 
					
						
							| 
									
										
										
										
											2022-09-27 17:30:34 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-24 08:05:00 +02:00
										 |  |  | " Literals {{{2 | 
					
						
							|  |  |  | syn keyword hareBoolean false true | 
					
						
							|  |  |  | syn keyword hareConstant null | 
					
						
							| 
									
										
										
										
											2022-09-27 17:30:34 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-24 08:05:00 +02:00
										 |  |  | " Integer literals. | 
					
						
							|  |  |  | syn match hareNumber '\v<%(0|[1-9]%(_?\d)*)%([Ee]\+?\d+)?%([iu]%(8|16|32|64)?|z)?>' display | 
					
						
							|  |  |  | syn match hareNumber '\v<0b[01]%(_?[01])*%([iu]%(8|16|32|64)?|z)?>' display | 
					
						
							|  |  |  | syn match hareNumber '\v<0o\o%(_?\o)*%([iu]%(8|16|32|64)?|z)?>' display | 
					
						
							|  |  |  | syn match hareNumber '\v<0x\x%(_?\x)*%([iu]%(8|16|32|64)?|z)?>' display | 
					
						
							| 
									
										
										
										
											2022-09-27 17:30:34 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-24 08:05:00 +02:00
										 |  |  | " Floating-point literals. | 
					
						
							|  |  |  | syn match hareFloat '\v<%(0|[1-9]%(_?\d)*)\.\d%(_?\d)*%([Ee][+-]?\d+)?%(f32|f64)?>' display | 
					
						
							|  |  |  | syn match hareFloat '\v<%(0|[1-9]%(_?\d)*)%([Ee][+-]?\d+)?%(f32|f64)>' display | 
					
						
							|  |  |  | syn match hareFloat '\v<0x\x%(_?\x)*%(\.\x%(_?\x)*)?[Pp][+-]?\d+%(f32|f64)?>' display | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | " Rune and string literals. | 
					
						
							|  |  |  | syn region hareRune start="'" skip="\\'" end="'" contains=hareEscape | 
					
						
							|  |  |  | syn region hareString start='"' skip='\\"' end='"' contains=hareEscape,hareFormat | 
					
						
							|  |  |  | syn region hareString start='`' end='`' contains=hareFormat | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | " Escape sequences. | 
					
						
							|  |  |  | syn match hareEscape '\\[0abfnrtv\\'"]' contained | 
					
						
							|  |  |  | syn match hareEscape '\v\\%(x\x{2}|u\x{4}|U\x{8})' contained display | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | " Format sequences. | 
					
						
							|  |  |  | syn match hareFormat '\v\{\d*%(:%(\.?\d+|[ +\-=Xbefgox]|F[.2ESUs]|_%(.|\\%([0abfnrtv\\'"]|x\x{2}|u\x{4}|U\x{8})))*)?}' contained contains=hareEscape display | 
					
						
							|  |  |  | syn match hareFormat '{\d*%\d*}' contained display | 
					
						
							|  |  |  | syn match hareFormat '{{\|}}' contained display | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | " Miscellaneous {{{2 | 
					
						
							| 
									
										
										
										
											2022-09-27 17:30:34 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | " Comments. | 
					
						
							| 
									
										
										
										
											2024-05-24 08:05:00 +02:00
										 |  |  | syn region hareComment start='//' end='$' contains=hareTodo,@haredoc,@Spell display | 
					
						
							|  |  |  | syn keyword hareTodo FIXME TODO XXX contained | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | " Identifiers. | 
					
						
							|  |  |  | syn match hareDelimiter '::' display | 
					
						
							|  |  |  | syn match hareName '\<\h\w*\>' nextgroup=@harePostfix skipempty skipwhite transparent | 
					
						
							| 
									
										
										
										
											2022-09-27 17:30:34 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-24 08:05:00 +02:00
										 |  |  | " Labels. | 
					
						
							|  |  |  | syn match hareLabel ':\h\w*\>' display | 
					
						
							| 
									
										
										
										
											2022-09-27 17:30:34 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-24 08:05:00 +02:00
										 |  |  | " Match `size` as a type unless it is followed by an open paren. | 
					
						
							|  |  |  | syn match hareType '\<size\>' display | 
					
						
							|  |  |  | syn match hareBuiltin '\<size\ze(' display | 
					
						
							| 
									
										
										
										
											2022-09-27 17:30:34 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-24 08:05:00 +02:00
										 |  |  | " Postfix expressions. | 
					
						
							|  |  |  | syn cluster harePostfix contains=hareErrorTest,hareField,hareIndex,hareParens | 
					
						
							|  |  |  | syn match hareErrorTest '!=\@!' contained nextgroup=@harePostfix skipempty skipwhite | 
					
						
							|  |  |  | syn match hareErrorTest '?' nextgroup=@harePostfix skipempty skipwhite | 
					
						
							|  |  |  | syn match hareField '\.\w*\>'hs=s+1 contained contains=hareNumber nextgroup=@harePostfix skipempty skipwhite | 
					
						
							|  |  |  | syn region hareIndex start='\[' end=']' contained nextgroup=@harePostfix skipempty skipwhite transparent | 
					
						
							|  |  |  | syn region hareParens start='(' end=')' nextgroup=@harePostfix skipempty skipwhite transparent | 
					
						
							| 
									
										
										
										
											2022-09-27 17:30:34 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-24 08:05:00 +02:00
										 |  |  | " Whitespace errors. | 
					
						
							|  |  |  | syn match hareSpaceError '^ \+\ze\t' display | 
					
						
							|  |  |  | syn match hareSpaceError excludenl '\s\+$' containedin=ALL display | 
					
						
							| 
									
										
										
										
											2022-09-27 17:30:34 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-24 08:05:00 +02:00
										 |  |  | " Folding {{{3 | 
					
						
							|  |  |  | syn region hareBlock start='{' end='}' fold transparent | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | " Default highlighting {{{1 | 
					
						
							|  |  |  | hi def link hareAttribute PreProc | 
					
						
							| 
									
										
										
										
											2022-09-27 17:30:34 +01:00
										 |  |  | hi def link hareBoolean Boolean | 
					
						
							| 
									
										
										
										
											2024-05-24 08:05:00 +02:00
										 |  |  | hi def link hareBuiltin Operator | 
					
						
							| 
									
										
										
										
											2022-09-27 17:30:34 +01:00
										 |  |  | hi def link hareComment Comment | 
					
						
							|  |  |  | hi def link hareConditional Conditional | 
					
						
							| 
									
										
										
										
											2024-05-24 08:05:00 +02:00
										 |  |  | hi def link hareConstant Constant | 
					
						
							|  |  |  | hi def link hareDefine Define | 
					
						
							|  |  |  | hi def link hareDelimiter Delimiter | 
					
						
							|  |  |  | hi def link hareErrorTest Special | 
					
						
							| 
									
										
										
										
											2022-09-27 17:30:34 +01:00
										 |  |  | hi def link hareEscape SpecialChar | 
					
						
							|  |  |  | hi def link hareFloat Float | 
					
						
							|  |  |  | hi def link hareFormat SpecialChar | 
					
						
							| 
									
										
										
										
											2024-05-24 08:05:00 +02:00
										 |  |  | hi def link hareInclude Include | 
					
						
							| 
									
										
										
										
											2022-09-27 17:30:34 +01:00
										 |  |  | hi def link hareKeyword Keyword | 
					
						
							| 
									
										
										
										
											2024-05-24 08:05:00 +02:00
										 |  |  | hi def link hareLabel Special | 
					
						
							| 
									
										
										
										
											2022-09-27 17:30:34 +01:00
										 |  |  | hi def link hareNumber Number | 
					
						
							|  |  |  | hi def link hareOperator Operator | 
					
						
							|  |  |  | hi def link hareRepeat Repeat | 
					
						
							|  |  |  | hi def link hareRune Character | 
					
						
							|  |  |  | hi def link hareStorageClass StorageClass | 
					
						
							|  |  |  | hi def link hareString String | 
					
						
							|  |  |  | hi def link hareStructure Structure | 
					
						
							|  |  |  | hi def link hareTodo Todo | 
					
						
							|  |  |  | hi def link hareType Type | 
					
						
							|  |  |  | hi def link hareTypedef Typedef | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-24 08:05:00 +02:00
										 |  |  | " Highlight embedded haredoc references. | 
					
						
							|  |  |  | hi! def link haredocRefValid SpecialComment | 
					
						
							| 
									
										
										
										
											2022-09-27 17:30:34 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-24 08:05:00 +02:00
										 |  |  | " Highlight whitespace errors by default. | 
					
						
							|  |  |  | if get(g:, 'hare_space_error', 1) | 
					
						
							|  |  |  |   hi def link hareSpaceError Error | 
					
						
							|  |  |  | endif | 
					
						
							| 
									
										
										
										
											2022-09-27 17:30:34 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-24 08:05:00 +02:00
										 |  |  | " vim: et sts=2 sw=2 ts=8 |