summaryrefslogtreecommitdiffstats
path: root/syntax/julia.vim
blob: 9dab3c86cc67ccc0f17eaba30a55aafbfe0dc44f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149

if exists("b:current_syntax")
  finish
endif

syn case match


syn keyword juliaDirective import importall export using require include

hi def link juliaDirective Include

syn region juliaDeclTypeBlock transparent matchgroup=juliaDeclType start="\<\%(type\|immutable\)\>" end="\<end\>" contains=ALL
syn keyword juliaTypeAlias typealias
syn keyword juliaDeclAbstract abstract

hi def link juliaDeclType  Structure
hi def link juliaTypeAlias Typedef
hi def link juliaDeclAbstract Structure

" Module
syn region juliaModuleBlock transparent matchgroup=juliaModule start="\<module\>" end="\<end\>" contains=ALL

hi def link juliaModule Structure


" Misc. blocks
syn region juliaMiscBlockBlock transparent matchgroup=juliaMiscBlock start="\<\%(quote\|do\|begin\|let\)\>" end="\<end\>" contains=ALL

hi def link juliaMiscBlock Repeat

" Braces and Brackets
syn region juliaBracketsBlock matchgroup=juliaBrackets start='\[' end='\]' contains=ALLBUT,juliaRepeatBlock contained
syn region juliaBracesBlock matchgroup=juliaBraces start='{' end='}' contains=ALLBUT,juliaRepeatBlock contained

" Repeat
syn region juliaRepeatBlock transparent matchgroup=juliaRepeat start="\<\%(while\|for\)\>" end="\<end\>" contains=@juliaTop

hi def link juliaRepeat    Repeat

" Conditional
syn keyword juliaElse else elseif
syn region  juliaIfBlock transparent matchgroup=juliaIf start="\<if\>" end="\<end\>" contains=@juliaTop

hi def link juliaElse Conditional
hi def link juliaIf   Conditional


" try catch end
syn keyword juliaCatch    catch contained
syn region  juliaTryBlock transparent matchgroup=juliaTry start="\<try\>" end="\<end\>" contains=@juliaTop

hi def link juliaTry Exception
hi def link juliaCatch Exception


" one word statements
syn keyword juliaStatement return continue break

hi def link juliaStatement Statement

" misc
syn keyword juliaDeclaration const global local
syn keyword juliaComprehensionFor for

hi def link juliaDeclaration Keyword
hi def link juliaComprehensionFor Keyword

" Built in types
syn keyword juliaType Uint Uint8 Uint16 Uint32 Uint64 Uint128
syn keyword juliaType Int Int8 Int16 Int32 Int64 Int128
syn keyword juliaType Float Float16 Float32 Float64
syn keyword juliaType AbstractArray AbstractMatrix AbstractVector Array Vector Matrix
syn keyword juliaType String ByteString UTF8String SubString
syn keyword juliaType Bool Nothing Union Type


hi def link juliaType Type


" Comments
syn keyword juliaTodo         contained TODO FIXME XXX
syn cluster juliaCommentGroup contains=juliaTodo
syn region  juliaComment      start="#" end="$" contains=@juliaCommentGroup,@Spell

hi def link juliaComment Comment
hi def link juliaTodo    Todo


" Strings
syn region juliaString       start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=@juliaStringGroup,@Spell
syn region juliaTripleString start=+"""+ end=+"""+
syn region juliaCharacter    start=+'+ skip=+\\\\\|\\'+ end=+'+ contains=@juliaCharacterGroup

hi def link juliaString        String
hi def link juliaTripleString  String
hi def link juliaCharacter     Character


" Functions
syn region juliaFunctionBlock transparent matchgroup=juliaFunction start="\<\%\(function\|macro\)\>" end="\<end\>" contains=@juliaTop
hi def link juliaFunction Function


" Numbers
syn match juliaNumber "\<\d\+\([Ee]\d\+\)\?\>"
syn match juliaNumber "\<0x\x\+\>"
syn match juliaNumber "\<0\o\+\>"

syn match juliaFloat "\<\d\+\.\d*\([Ee][-+]\d\+\)\?\>"
syn match juliaFloat "\<\.\d\+\([Ee][-+]\d\+\)\?\>"
syn match juliaFloat "\<\d\+[Ee][-+]\d\+\>"
syn keyword juliaFloatSpecial NaN Inf

hi def link juliaNumber Number
hi def link juliaFloat Float
hi def link juliaFloatSpecial Float


" Operators
syn keyword juliaIn in
hi def link juliaIn Operator


" Constants
syn keyword juliaBool true false nothing
hi def link juliaBool Boolean

syn keyword juliaIdentifierSpecial STDOUT, STDIN, STDERR

hi def link juliaIdentifierSpecial Identifier


" Macros
syn match juliaMacro display "@[_[:alpha:]][_[:alnum:]!]*\%(\.[_[:alpha:]][_[:alnum:]!]*\)*"

hi def link juliaMacro Macro


syn cluster juliaTop contains=ALLBUT,juliaComprehensionFor

" Ragel
syn include @ragel syntax/ragel.vim
syn region ragelLine  start="%%" end="$" contains=@ragel


let b:current_syntax = "julia"