forked from gerardroche/sublime-pine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPine.sublime-syntax
227 lines (162 loc) · 7.89 KB
/
Pine.sublime-syntax
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
%YAML 1.2
---
name: Pine
file_extensions:
- pine
scope: source.pine
variables:
identifier_regex: '[a-zA-Z_][a-zA-Z0-9_]*'
contexts:
main:
- match: //.*
scope: comment.pine
#constant:
- match: \b(bool|true|false)\b
scope: constant.language.pine
- match: \b(timenow|year|month|weekofyear|dayofmonth|hour|minute|second|interval|isdaily|isdwm|isintraday|ismonthly|isweekly)\b
scope: constant.language.pine
- match: \b(time)\_(close|tradingday)\b
scope: constant.language.pine
- match: \b(timeframe)\.(isdaily|isdwm|isintraday|isminutes|ismonthly|isseconds|isweekly|multiplier|period)\b
scope: constant.language.pine
- match: \b(open|high|low|close|hl2|hlc3|hlcc4|volume|na|period|tickerid|source|symbol)\b
scope: constant.language.pine
- match: \b(xloc.bar)\.(index|time)\b
scope: constant.language.pine
- match: \b(yloc)\.(abovebar|belowbar|price)\b
scope: constant.language.pine
- match: \b(accdist|area|areabr|hl(2|c3)|ohlc4)\b
scope: constant.language.pine
- match: \b(table.all)\b
scope: constant.language.pine
- match: \b(text)\.(align|wrap)\_(bottom|center|left|right|top|auto|none)\b
scope: constant.language.pine
- match: \b(ta)\.(accdist|iii|nvi|obv|pvi|pvt|tr|vwap|wad|wvad)\b
scope: constant.language.pine
- match: \b(adjustment)\.(dividends|none|splits)\b
scope: constant.language.pine
- match: \b(splits)\.(denominator|numerator)\b
scope: constant.language.pine
- match: \b(position)\.(bottom|middle|top)\_(center|left|right)\b
scope: constant.language.pine
- match: \b(alert)\.(freq_all|freq_once_per_bar|freq_once_per_bar_close)\b
scope: constant.language.pine
- match: \b(dayofweek|dayofweek.(monday|tuesday|wednesday|thursday|friday|saturday|sunday))\b
scope: constant.language.pine
- match: \b(line|stepline|histogram|cross[^\(]|area|columns|circles)\b
scope: constant.language.pine
- match: \b(solid|dotted|dashed)\b
scope: constant.language.pine
- match: \b(bar_index)\b
scope: constant.language.pine
- match: \b(session|session.(extended|regular|ismarket|ispostmarket|ispremarket))\b
scope: constant.language.pine
- match: \b(scale).(left|none|right)\b
scope: constant.language.pine
- match: \b(barmerge)\.(gaps_(off|on)|lookahead_(off|on))\b
scope: constant.language.pine
- match: \b(barstate)\.is(confirmed|first|history|last|new|realtime|islastconfirmedhistory)\b
scope: constant.language.pine
- match: \b(box)\.(all)\b
scope: constant.language.pine
- match: \b(currency)\.(AUD|CAD|CHF|EUR|GBP|HKD|JPY|NOK|NONE|NZD|RUB|SEK|SGD|TRY|USD|ZAR)\b
scope: constant.language.pine
- match: \b(display)\.(all|none)\b
scope: constant.language.pine
- match: \b(label)\.(all)\b
scope: constant.language.pine
- match: \b(math)\.(e|phi|pi|rphi)\b
scope: constant.language.pine
- match: \b(label.style)\_(arrowdown|arrowup|circle|cross|diamond|flag|label_center|label_down|label_left|label_lower_left|label_lower_right|label_upper_left|label_upper_right|none|square|triangledown|triangleup|xcross)\b
scope: constant.language.pine
- match: \b(last_bar)\.(index|time)\b
scope: constant.language.pine
- match: \b(earnings)\.(actual|estimate|standardized)\b
scope: constant.language.pine
- match: \b(extend)\.(both|left|none|right)\b
- match: \b(location)\.(abovebar|belowbar|top|bottom|absolute)\b
scope: constant.language.pine
- match: \b(line.all)\b
scope: constant.language.pine
- match: \b(linefill.all)\b
scope: constant.language.pine
- match: \b(line.style)\_(arrow_both|arrow_left|arrow_right|dashed|dotted|solid)\b
scope: constant.language.pine
- match: \b(hline.style)\_(dashed|dotted|solid)\b
scope: constant.language.pine
- match: \b(format)\.(inherit|mintick|percent|price|volume)\b
scope: constant.language.pine
- match: \bshape\.(x(cross)?|(triangle|arrow|label)(up|down)|flag|circle|square|diamond)\b
scope: constant.language.pine
- match: \bshape\.(arrowdown|arrowup|circle|cross|diamond|flag|labeldown|labelup|square|triangledown|triangleup)\b
scope: constant.language.pine
- match: \bsize\.(auto|huge|large|normal|small|tiny)\b
scope: constant.language.pine
- match: \b(plot.style)\_(area|areabr|circles|columns|cross|histogram|line|linebr|stepline|stepline_diamond)\b
scope: constant.language.pine
- match: \bstrategy\.(cash|closedtrades|commission\.(cash_per_contract|cash_per_order|percent)|direction\.(all|long|short)|equity|eventrades|fixed|grossloss|grossprofit|initial_capital|long|losstrades|max_contracts_held_all|max_contracts_held_long|max_contracts_held_short|max_drawdown|netprofit|oca\.(cancel|none|reduce)|openprofit|opentrades|percent_of_equity|position_avg_price|position_entry_name|position_size|short|wintrades)(account_currency)\b
scope: constant.language.pine
- match: \bsyminfo\.(basecurrency|currency|description|mintick|pointvalue|prefix|root|session|ticker|tickerid|timezone|type)\b
scope: constant.language.pine
- match: \b(color)\.(aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|orange|purple|red|silver|teal|white|yellow)\b
scope: constant.language.pine
- match: \b(dividends)\.(gross|net)\b
scope: constant.language.pine
- match: \b(order)\.(ascending|descending)\b
scope: constant.language.pine
- match: '#[a-fA-F0-9]{6}'
scope: support.constant.pine
- match: '\b([0-9]+)\b'
scope: constant.numeric.pine
- match: \b(int)\b
scope: constant.numeric.integer.pine
- match: \b(float)\b
scope: constant.numeric.float.pine
# var
- match: \b(var|varip)\b
scope: variable.other.pine
# strings
- match: ''''
push: single-quoted-string
- match: '"'
push: double-quoted-string
- match: \b(string)\b
scope: string.pine
# operators
- match: (\-|\+|\*|\/|\%|\*=|\+=|\-=|\/=)
scope: keyword.operator.arithmetic.pine
- match: (==|!=|<=|=>|>=|<|>|\:=|%=)
scope: keyword.operator.comparison.pine
- match: (\?|\:)
scope: keyword.operator.ternary.pine
- match: \b(and|or|not)\b
scope: keyword.operator.logical.pine
- match: "="
scope: keyword.operator.assignment.pine
# control
- match: \b(//@version=5|export|import|series|simple|switch|)\b
scope: keyword.control.import.pine
- match: (|if|else|for|for...in|while)
scope: keyword.control.conditional.pine
# functions
- match: '\b(alertcondition|a(bs|cos|lma|sin|tan|tr|vg)|bar(color|since)|bgcolor|cci|ceil|change|cog|color|correlation|cos|cross(over|under)?|cum|dayof(month|week)|dev|(e|s)ma|exp|falling|fill|fixnan|floor|heikinashi|highest(bars)?|hline|iff|input|kagi|linebreak|linreg|log(10)?|lowest(bars)?|macd|m(ax|in)|minute|mom|month|n(a|z)|offset|percentile_linear_(interpolation|nearest_rank)|percentrank|pivot(high|low)|plot(arrow|bar|candle|char|shape|figure)?|pow|renko|rising|r(ma|oc|si)|round|sar|second|security|sign|sin|sqrt|stdev|stoch|strategy|strategy\.(cancel|cancel_all|close|close_all|entry|exit|order)|study|sum|swma|tan|tickerid|time(stamp)?|tostring|tr|tsi|valuewhen|variance|v(wap|wma)|weekofyear|wma|year|{{identifier_regex}})(?=\()'
captures:
1: support.function.pine
- match: '{{identifier_regex}}\s*(?=:?\=)'
scope: variable.parameter.pine
- match: ('({{identifier_regex}})\(.*\)\s(=>)\s')
captures:
1: entity.name.function
2: keyword.operator.assignment.pine
single-quoted-string:
- meta_scope: string.quoted.single.pine
- match: \\.
scope: constant.character.escape.pine
- match: ''''
pop: true
double-quoted-string:
- meta_scope: string.quoted.double.pine
- match: \\.
scope: constant.character.escape.pine
- match: '"'
pop: true