Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes15kdownloads
hare.vim263 linesDownload Raw Back to syntax
1vim9script2 3# Vim syntax file.4# Language:    Hare5# Maintainer:  Amelia Clarke <selene@perilune.dev>6# Last Change: 2026 Feb 157# Upstream:    https://git.sr.ht/~sircmpwn/hare.vim8 9if exists('b:current_syntax')10  finish11endif12 13# Syntax {{{114syn case match15syn iskeyword @,48-57,@-@,_16 17# Identifiers {{{218syn cluster hareIdentifier contains=hareName,hareScopeDelimiter,@hareReserved19syn match hareIdentifier '\v<\h\w*%(::\h\w*)*>' contains=@hareIdentifier nextgroup=hareScopeDelimiter,@harePostfix skipempty skipwhite20syn match hareName '\<\h\w*\>' contained transparent21 22# Reserved keywords.23syn cluster hareReserved contains=hareBoolean,hareBuiltin,hareConditional,hareConstant,hareDefine,hareInclude,hareKeyword,hareLabel,hareOperator,hareRepeat,hareStatement,hareStorageClass,hareStructure,hareType,hareTypedef24 25# Punctuators {{{226 27# Balanced tokens.28syn region hareBraces matchgroup=hareBrace start='{' end='}' contains=TOP fold transparent29syn region hareBrackets matchgroup=hareBracket start='\[' end=']' contains=TOP transparent30syn region hareParens matchgroup=hareParen start='(' end=')' contains=TOP nextgroup=@harePostfix skipempty skipwhite transparent31 32# Symbolic operators.33syn match hareSymbolOperator '\.\{2,3}'34syn match hareSymbolOperator '[!<=>]=\?'35syn match hareSymbolOperator '=>'36 37# Additive and multiplicative arithmetic.38syn match hareSymbolOperator '[-+*/%]=\?'39 40# Bitwise arithmetic.41syn match hareSymbolOperator '\%(<<\|>>\)=\?'42syn match hareSymbolOperator '[&^|]=\?'43syn match hareSymbolOperator '\~'44 45# Logical arithmetic.46syn match hareSymbolOperator '\%(&&\|^^\|||\)=\?'47 48# Types {{{249syn cluster hareType contains=hareArray,hareError,harePointer,hareStorageClass,hareStructure,hareTaggedUnion,hareType50syn keyword hareType bool51syn keyword hareType done52syn keyword hareType f32 f6453syn keyword hareType i8 i16 i32 i64 int54syn keyword hareType never55syn keyword hareType nomem56syn keyword hareType opaque57syn keyword hareType rune str58syn keyword hareType u8 u16 u32 u64 uint uintptr59syn keyword hareType void60 61# C ABI.62syn keyword hareType valist63 64# Pointer types.65syn match harePointer '*' contained containedin=hareTaggedUnion,hareTypeParens nextgroup=@hareType skipempty skipwhite66syn keyword hareStorageClass nullable nextgroup=harePointer skipempty skipwhite67 68# Slice and array types.69syn region hareArray matchgroup=hareBracket start='\[' end=']' contained containedin=hareTaggedUnion,hareTypeParens contains=TOP nextgroup=@hareType skipempty skipwhite transparent70syn match hareArray '\[[*_]]' contains=hareArrayBounds nextgroup=@hareType skipempty skipwhite transparent71syn match hareArrayBounds '*' contained display72 73# Tagged union and tuple types.74syn region hareTaggedUnion matchgroup=hareParen start='(' end=')' contained containedin=hareTaggedUnion,hareTypeParens contains=TOP transparent75syn match hareTaggedUnionBar '|' contained containedin=hareTaggedUnion76 77# Other types.78syn match hareError '!' contained containedin=hareTaggedUnion,hareTypeParens nextgroup=@hareType skipempty skipwhite79syn keyword hareStructure enum struct union80 81# Declarations {{{282syn keyword hareDefine def83syn keyword hareInclude use84syn keyword hareKeyword export static85syn keyword hareKeyword fn nextgroup=@hareFunction,@hareReserved skipempty skipwhite86syn keyword hareStatement const let87syn keyword hareTypedef type nextgroup=hareTypedefBinding,@hareReserved skipempty skipwhite88 89# Highlight `const` as a storage-class in places types are expected.90syn keyword hareStorageClass const contained containedin=hareTaggedUnion,hareTypeParens nextgroup=@hareType skipempty skipwhite91 92# Function declarations.93syn cluster hareFunction contains=hareFunction,hareFunctionParams94syn match hareFunction '\v<\h\w*%(::\h\w*)*>' contained contains=@hareIdentifier nextgroup=hareFunctionParams skipempty skipwhite95syn region hareFunctionParams matchgroup=hareParen start='(' end=')' contained contains=TOP nextgroup=@hareType skipempty skipwhite transparent96 97# Type declarations.98# XXX: Does not yet account for type declarations with multiple bindings.99syn match hareTypedefBinding '\v<\h\w*%(::\h\w*)*>' contained nextgroup=hareTypedefEquals skipempty skipwhite transparent100syn match hareTypedefEquals '=' contained nextgroup=@hareType skipempty skipwhite transparent101 102# Attributes {{{3103syn keyword hareAttribute @init @fini @test104syn keyword hareAttribute @packed105syn keyword hareAttribute @symbol nextgroup=hareAttributeParens skipempty skipwhite106syn keyword hareAttribute @threadlocal107syn keyword hareAttribute @undefined108 109# Match the parens following attributes.110syn region hareAttributeParens matchgroup=hareParen start='(' end=')' contained contains=TOP transparent111 112# Expressions {{{2113syn keyword hareConditional else114syn keyword hareConditional if nextgroup=hareConditionParens skipempty skipwhite115syn keyword hareConditional match switch nextgroup=@hareCondition skipempty skipwhite116syn keyword hareLabel case nextgroup=@hareType skipempty skipwhite117syn keyword hareOperator as is nextgroup=@hareType skipempty skipwhite118syn keyword hareRepeat for nextgroup=@hareCondition skipempty skipwhite119syn keyword hareStatement break continue return yield120syn keyword hareStatement defer121 122# Match the parens in conditionals and loops.123syn cluster hareCondition contains=hareConditionLabel,hareConditionParens124syn match hareConditionLabel ':\h\w*\>' contained nextgroup=hareConditionParens skipempty skipwhite transparent125syn region hareConditionParens matchgroup=hareParen start='(' end=')' contained contains=TOP transparent126 127# Builtins {{{3128syn keyword hareBuiltin abort assert129syn keyword hareBuiltin align nextgroup=hareTypeParens skipempty skipwhite130syn keyword hareBuiltin alloc free131syn keyword hareBuiltin append insert delete132syn keyword hareBuiltin len offset133 134# C ABI.135syn keyword hareBuiltin vastart vaarg vaend136 137# Highlight `size` as a type unless it is followed by an open paren.138syn match hareType '\<size\>'139syn match hareBuiltin '\<size\ze(' nextgroup=hareTypeParens140 141# Match the parens in builtin expressions expecting a type.142syn region hareTypeParens matchgroup=hareParen start='(' end=')' contained contains=TOP nextgroup=@harePostfix skipempty skipwhite transparent143 144# Postfix expressions {{{3145# TODO: Match postfix expressions after literals.146syn cluster harePostfix contains=hareCast,hareField,hareSlice,hareSpecial147 148# Casts and type hints.149syn match hareCast ':' nextgroup=@hareType skipempty skipwhite150 151# Error checking.152syn match hareSpecial '!=\@!' contained nextgroup=@harePostfix skipempty skipwhite153syn match hareSpecial '?' nextgroup=@harePostfix skipempty skipwhite154 155# Field access.156syn match hareField '\.\w\+\>' contained contains=hareName,hareNumber,@hareReserved nextgroup=@harePostfix skipempty skipwhite transparent157 158# Indexing and slicing.159syn region hareSlice matchgroup=hareBracket start='\[' end=']' contained contains=TOP nextgroup=@harePostfix skipempty skipwhite transparent160 161# Literals {{{2162syn keyword hareBoolean true false163syn keyword hareConstant null164 165# Integers {{{3166syn match hareNumber '\v<%(0|[1-9]%(_?\d)*)%([Ee]\+?\d+)?%([iu]%(8|16|32|64)?|z)?>'167syn match hareNumber '\v<0b[01]%(_?[01])*%([iu]%(8|16|32|64)?|z)?>'168syn match hareNumber '\v<0o\o%(_?\o)*%([iu]%(8|16|32|64)?|z)?>'169syn match hareNumber '\v<0x\x%(_?\x)*%([iu]%(8|16|32|64)?|z)?>'170 171# Floats {{{3172# XXX: Technically, the third form is not a valid floating literal according to173#      the specification, but is currently accepted by the Hare compiler and174#      used occasionally within the standard library.175syn match hareFloat '\v<%(0|[1-9]%(_?\d)*)\.\d%(_?\d)*%([Ee][+-]?\d+)?%(f32|f64)?>'176syn match hareFloat '\v<%(0|[1-9]%(_?\d)*)%([Ee][+-]?\d+)?%(f32|f64)>'177syn match hareFloat '\v<%(0|[1-9]%(_?\d)*)[Ee]-\d+>'178syn match hareFloat '\v<0x\x%(_?\x)*%(\.\x%(_?\x)*)?[Pp][+-]?\d+%(f32|f64)?>'179 180# Rune and string literals {{{3181syn region hareRune matchgroup=hareRuneDelimiter start="'" skip="\\'" end="'" contains=hareEscape182syn region hareString matchgroup=hareStringDelimiter start='"' skip='\\"' end='"' contains=hareEscape,hareFormat183syn region hareString matchgroup=hareStringDelimiter start='`' end='`' contains=hareFormat184 185# Escape sequences.186syn match hareEscape '\\[0abfnrtv\\'"]' contained187syn match hareEscape '\v\\%(x\x{2}|u\x{4}|U\x{8})' contained display188 189# Format sequences.190syn match hareFormat '\v\{\d*%(:%(\.?\d+|[- +=befgoxX]|F[.2EsSU]|_%(\_[^\\]|\\%([0abfnrtv\\'"]|x\x{2}|u\x{4}|U\x{8})))*)?}' contained contains=hareEscape191syn match hareFormat '{\d*%\d*}' contained display192syn match hareFormat '{{\|}}' contained193 194# Miscellaneous {{{2195 196# Annotations.197syn region hareAnnotation start='#\[' end=']' contains=hareAnnotationIdentifier,hareComment,hareRune,hareString198syn match hareAnnotationIdentifier '\v#\[\s*\zs\h\w*%(::\h\w*)*>' contained contains=hareName,@hareReserved nextgroup=hareAnnotationParens skipempty skipwhite199syn region hareAnnotationParens matchgroup=hareAnnotationParen start='(' end=')' contained contains=TOP200 201# Comments.202syn region hareComment excludenl start='//' end='$' contains=hareSpecialComment,hareTodo,@Spell203syn match hareSpecialComment '\v\[\[\h\w*%(::\h\w*)*%(::)?]]' contained contains=@NoSpell display204syn keyword hareTodo FIXME TODO XXX contained205 206# Scope delimiters.207syn match hareScopeDelimiter '::'208 209# User labels.210syn match hareUserLabel ':\h\w*\>' contains=hareName,@hareReserved211 212# Default highlighting {{{1213hi def link hareAnnotation Special214hi def link hareAnnotationIdentifier hareAnnotation215hi def link hareAnnotationParen hareAnnotation216hi def link hareArrayBounds harePointer217hi def link hareAttribute PreProc218hi def link hareBoolean Boolean219hi def link hareBuiltin hareOperator220hi def link hareComment Comment221hi def link hareConditional Conditional222hi def link hareConstant Constant223hi def link hareDefine Define224hi def link hareError hareSpecial225hi def link hareEscape SpecialChar226hi def link hareFloat Float227hi def link hareFormat SpecialChar228hi def link hareFunction Function229hi def link hareInclude Include230hi def link hareKeyword Keyword231hi def link hareLabel Label232hi def link hareNumber Number233hi def link hareOperator Operator234hi def link harePointer hareStorageClass235hi def link hareRepeat Repeat236hi def link hareRune Character237hi def link hareRuneDelimiter hareRune238hi def link hareScopeDelimiter Delimiter239hi def link hareSpecial Special240hi def link hareSpecialComment SpecialComment241hi def link hareStatement Statement242hi def link hareStorageClass StorageClass243hi def link hareString String244hi def link hareStringDelimiter hareString245hi def link hareStructure Structure246hi def link hareTodo Todo247hi def link hareType Type248hi def link hareTypedef Typedef249hi def link hareUserLabel Identifier250 251# Highlight incorrect whitespace by default.252syn match hareSpaceError excludenl '\s\+$' containedin=ALL display253syn match hareSpaceError ' \+\ze\t' display254if get(g:, 'hare_space_error', 1)255  hi! def link hareSpaceError Error256else257  hi! def link hareSpaceError NONE258endif259 260b:current_syntax = 'hare'261 262# vim: fdm=marker et sts=2 sw=2 ts=8 tw=80263 
codekingpro/portable-devtools · Team Ai