blob: fed75510434ccf4c07fabc26f808d14884e7fce6 [file] [log] [blame]
Anton Parkhomenko7159ac72023-08-09 21:50:52 +07001" Vim syntax file
2"
3" Language: unison
4" Maintainer: Anton Parkhomenko <anton@chuwy.me>
5" Last Change: Aug 7, 2023
6" Original Author: John Williams, Paul Chiusano and Rúnar Bjarnason
7
8if exists("b:current_syntax")
9 finish
10endif
11
12syntax include @markdown $VIMRUNTIME/syntax/markdown.vim
13
14syn cluster markdownLikeDocs contains=markdownBold,markdownItalic,markdownLinkText,markdownListMarker,markdownOrderedListMarker,markdownH1,markdownH2,markdownH3,markdownH4,markdownH5,markdownH6
15
16syn match unisonOperator "[-!#$%&\*\+/<=>\?@\\^|~]"
17syn match unisonDelimiter "[\[\](){},.]"
18
19" Strings and constants
20syn match unisonSpecialChar contained "\\\([0-9]\+\|o[0-7]\+\|x[0-9a-fA-F]\+\|[\"\\'&\\abfnrtv]\|^[A-Z^_\[\\\]]\)"
21syn match unisonSpecialChar contained "\\\(NUL\|SOH\|STX\|ETX\|EOT\|ENQ\|ACK\|BEL\|BS\|HT\|LF\|VT\|FF\|CR\|SO\|SI\|DLE\|DC1\|DC2\|DC3\|DC4\|NAK\|SYN\|ETB\|CAN\|EM\|SUB\|ESC\|FS\|GS\|RS\|US\|SP\|DEL\)"
22syn match unisonSpecialCharError contained "\\&\|'''\+"
23syn region unisonString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=unisonSpecialChar
24syn match unisonCharacter "[^a-zA-Z0-9_']'\([^\\]\|\\[^']\+\|\\'\)'"lc=1 contains=unisonSpecialChar,unisonSpecialCharError
25syn match unisonCharacter "^'\([^\\]\|\\[^']\+\|\\'\)'" contains=unisonSpecialChar,unisonSpecialCharError
26syn match unisonNumber "\<[0-9]\+\>\|\<0[xX][0-9a-fA-F]\+\>\|\<0[oO][0-7]\+\>"
27syn match unisonFloat "\<[0-9]\+\.[0-9]\+\([eE][-+]\=[0-9]\+\)\=\>"
28
29" Keyword definitions. These must be patterns instead of keywords
30" because otherwise they would match as keywords at the start of a
31" "literate" comment (see lu.vim).
32syn match unisonModule "\<namespace\>"
33syn match unisonImport "\<use\>"
34syn match unisonTypedef "\<\(unique\|structural\|\|forall\)\>"
35syn match unisonStatement "\<\(ability\|do\|type\|where\|match\|cases\|;\|let\|with\|handle\)\>"
36syn match unisonConditional "\<\(if\|else\|then\)\>"
37
38syn match unisonBoolean "\<\(true\|false\)\>"
39
40syn match unisonType "\<\C[A-Z][0-9A-Za-z_'!]*\>"
41syn match unisonName "\<\C[a-z_][0-9A-Za-z_'!]*\>"
42
43" Comments
44syn match unisonLineComment "---*\([^-!#$%&\*\+./<=>\?@\\^|~].*\)\?$"
45syn region unisonBlockComment start="{-" end="-}" contains=unisonBlockComment
46syn region unisonBelowFold start="^---" skip="." end="." contains=unisonBelowFold
47
48" Docs
49syn region unisonDocBlock matchgroup=unisonDoc start="{{" end="}}" contains=unisonDocTypecheck,unisonDocQuasiquote,unisonDocDirective,unisonDocCode,unisonDocCodeInline,unisonDocCodeRaw,unisonDocMono,@markdownLikeDocs
50syn region unisonDocQuasiquote contained matchgroup=unisonDocQuote start="{{" end= "}}" contains=TOP
51syn region unisonDocCode contained matchgroup=unisonDocCode start="^\s*```\s*$" end="^\s*```\s*$" contains=TOP
52syn region unisonDocTypecheck contained matchgroup=unisonDocCode start="^\s*@typecheck\s*```\s*$" end="^\s*```\s*$" contains=TOP
53syn region unisonDocCodeRaw contained matchgroup=unisonDocCode start="^\s*```\s*raw\s*$" end="^\s*```\s*$" contains=NoSyntax
54syn region unisonDocCodeInline contained matchgroup=unisonDocCode start="`\@<!``" end="`\@<!``" contains=TOP
55syn match unisonDocMono "''[^']*''"
56syn region unisonDocDirective contained matchgroup=unisonDocDirective start="\(@\([a-zA-Z0-9_']*\)\)\?{{\@!" end="}" contains=TOP
57
58syn match unisonDebug "\<\(todo\|bug\|Debug.trace\|Debug.evalToText\)\>"
59
60" things like
61" > my_func 1 3
62" test> Function.tap.tests.t1 = check let
63" use Nat == +
64" ( 99, 100 ) === (withInitialValue 0 do
65" : : :
66syn match unisonWatch "^[A-Za-z]*>"
67
68hi def link unisonWatch Debug
69hi def link unisonDocMono Delimiter
70hi def link unisonDocDirective Import
71hi def link unisonDocQuote Delimiter
72hi def link unisonDocCode Delimiter
73hi def link unisonDoc String
74hi def link unisonBelowFold Comment
75hi def link unisonBlockComment Comment
76hi def link unisonBoolean Boolean
77hi def link unisonCharacter Character
78hi def link unisonComment Comment
79hi def link unisonConditional Conditional
80hi def link unisonConditional Conditional
81hi def link unisonDebug Debug
82hi def link unisonDelimiter Delimiter
83hi def link unisonDocBlock String
84hi def link unisonDocDirective Import
85hi def link unisonDocIncluded Import
86hi def link unisonFloat Float
87hi def link unisonImport Include
88hi def link unisonLineComment Comment
89hi def link unisonLink Type
90hi def link unisonName Identifier
91hi def link unisonNumber Number
92hi def link unisonOperator Operator
93hi def link unisonSpecialChar SpecialChar
94hi def link unisonSpecialCharError Error
95hi def link unisonStatement Statement
96hi def link unisonString String
97hi def link unisonType Type
98hi def link unisonTypedef Typedef
99
100
101let b:current_syntax = "unison"
102
103" Options for vi: ts=8 sw=2 sts=2 nowrap noexpandtab ft=vim