813
Ns
nvim-bend-syntax / files
nvim-bend-syntax / syntax / bend.vim
2.1 KB
1" Vim syntax file for the Bend language (bend / bend2) 2" https://github.com/bendlang/bend 3if exists("b:current_syntax") 4 finish 5endif 6 7syn case match 8 9" Comments 10syn match bendComment "#.*$" contains=@Spell 11 12" Strings and characters 13syn match bendString /"\%([^"\\]\|\\.\)*"/ 14syn match bendChar /'\%([^'\\]\|\\.\)'/ 15 16" Numbers: U32 (42, 0xff), F32 (1.5, 2e10), Nat (3n) 17syn match bendNumber /\<0x\x\+\>/ 18syn match bendNumber /\<\d\+n\>/ 19syn match bendNumber /\<\d\+\>/ 20syn match bendFloat /\<\d\+\.\d\+\([eE][-+]\?\d\+\)\?\>/ 21 22" Operators (single-char first, multi-char override by being defined later) 23syn match bendOperator /[+*/%=<>!&|^-]/ 24syn match bendOperator /<&>\|->\|=>\|<-\|==\|!=\|++\|&&\|||\|<<\|>>/ 25syn match bendOperator /\.&\.\|\.|\.\|\.\^\|\// 26 27" Keywords 28syn keyword bendKeyword import as type is def law for exs where 29syn keyword bendKeyword match case do return unsafe 30syn keyword bendType Type Data Kind Quant 31 32" Names after def / type / law (lookbehind so the name is matched alone) 33syn match bendFunction /\%(\<def\s\+\)\@<=[A-Za-z_][A-Za-z0-9_.]*/ 34syn match bendType /\%(\<\(type\|law\)\s\+\)\@<=[A-Za-z_][A-Za-z0-9_.]*/ 35 36" Constructors / datatype names (capitalised identifiers) 37syn match bendConstructor /\<[A-Z][A-Za-z0-9_]*\>/ 38 39" Delimiters 40syn match bendDelimiter /[(){}\[\],;]/ 41 42" Special forms (defined last so they win over operators/delimiters) 43syn match bendQuantity /&[012]\>/ 44syn match bendReflexivity /{==}/ 45syn match bendHole /?\w\+/ 46 47hi def link bendComment Comment 48hi def link bendString String 49hi def link bendChar Character 50hi def link bendNumber Number 51hi def link bendFloat Float 52hi def link bendHole Todo 53hi def link bendQuantity Special 54hi def link bendReflexivity Special 55hi def link bendOperator Operator 56hi def link bendKeyword Keyword 57hi def link bendType Type 58hi def link bendFunction Function 59hi def link bendConstructor Constant 60hi def link bendDelimiter Delimiter 61 62let b:current_syntax = "bend"