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