Skip to content

Commit 0a2f0c5

Browse files
Yankı KüçükYankı Küçük
Yankı Küçük
authored and
Yankı Küçük
committed
Rocks
1 parent 981a4d6 commit 0a2f0c5

10 files changed

+320
-2
lines changed

.vscode/launch.json

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// A launch configuration that launches the extension inside a new window
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
{
6+
"version": "0.2.0",
7+
"configurations": [
8+
{
9+
"name": "Extension",
10+
"type": "extensionHost",
11+
"request": "launch",
12+
"runtimeExecutable": "${execPath}",
13+
"args": [
14+
"--extensionDevelopmentPath=${workspaceFolder}"
15+
]
16+
}
17+
]
18+
}

.vscodeignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.vscode/**
2+
.vscode-test/**
3+
.gitignore
4+
vsc-extension-quickstart.md

CHANGELOG.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Changelog
2+
All notable changes to this project will be documented in this file. And this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
3+
4+
## [Unreleased]
5+
- Regex improvements.
6+
7+
## [1.0.0] - 2019-08-25
8+
### Added
9+
- [Language operators](https://www.tradingview.com/pine-script-reference/#op_!=).
10+
- [Built-in variables](https://www.tradingview.com/pine-script-reference/#var_accdist)
11+
- [Built-in functions](https://www.tradingview.com/pine-script-reference/#fun_abs)

README.md

+19-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,19 @@
1-
# pine-script-syntax-highlight
2-
Pine Script Syntax highlight for VSCode
1+
<h1 align="center">
2+
<br>
3+
![PineScript](images/pinescript.png)
4+
<br>
5+
Pine Script Syntax Highlight
6+
<br>
7+
</h1>
8+
<h4 align="center">Create amazing indicators and strategies!</h4>
9+
<p align="center">
10+
<a><img src="https://img.shields.io/badge/Version-1.0.0-blue.svg" alt="Version"></a>
11+
<a><img src="https://img.shields.io/badge/status-BETA-orenge.svg" alt="Status"</a>
12+
<a><img src="https://img.shields.io/badge/platform-vscode-red.svg" alt="platforms"</a>
13+
</p>
14+
15+
## About
16+
17+
Pine Script Syntax Highlight is the simple syntax highlighter for Pine Script.
18+
19+
![Example](images/example.png)

images/example.png

83.2 KB
Loading

images/pinescript.png

3.11 KB
Loading

language-configuration.json

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"comments": {
3+
"lineComment": "//"
4+
},
5+
"brackets": [
6+
["{", "}"],
7+
["[", "]"],
8+
["(", ")"]
9+
],
10+
"autoClosingPairs": [
11+
{ "open": "{", "close": "}" },
12+
{ "open": "[", "close": "]" },
13+
{ "open": "(", "close": ")" },
14+
{ "open": "'", "close": "'", "notIn": ["string", "comment"] },
15+
],
16+
"surroundingPairs": [
17+
["{", "}"],
18+
["[", "]"],
19+
["(", ")"],
20+
["'", "'"]
21+
]
22+
}

package.json

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"name": "pine-script-syntax-highlight",
3+
"displayName": "Pine Script Syntax Highlight",
4+
"description": "Write awesome indicators or strategies with me!",
5+
"version": "1.0.0",
6+
"author": "Yankı Küçük <[email protected]> (https://github.com/kendinikertenkelebek)",
7+
"publisher": "ex.codes",
8+
"icon": "images/pinescript.png",
9+
"engines": {
10+
"vscode": "^1.37.0"
11+
},
12+
"categories": [
13+
"Language Packs",
14+
"Programming Languages",
15+
"Themes"
16+
],
17+
"contributes": {
18+
"languages": [{
19+
"id": "pinescript",
20+
"aliases": ["Pine Script", "pinescript", "Pine"],
21+
"extensions": [".pine"],
22+
"configuration": "./language-configuration.json"
23+
}],
24+
"grammars": [{
25+
"language": "pinescript",
26+
"scopeName": "source.pine",
27+
"path": "./syntaxes/pinescript.tmLanguage.json"
28+
}]
29+
},
30+
"homepage": "https://github.com/kendinikertenkelebek/",
31+
"repository": {
32+
"type": "git",
33+
"url": "https://github.com/kendinikertenkelebek/pine-script-syntax-highlight.git",
34+
"bugs": {
35+
"url": "https://github.com/kendinikertenkelebek/pine-script-syntax-highlight/issues"
36+
}
37+
},
38+
"license": "MIT"
39+
}

syntaxes/pinescript.tmLanguage.json

+196
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
3+
"name": "Pine Script",
4+
"patterns": [
5+
{
6+
"match": "//.*",
7+
"name": "comment.line.double-slash.pine"
8+
},
9+
{
10+
"include": "#strings"
11+
},
12+
{
13+
"include": "#keywords"
14+
},
15+
{
16+
"include": "#constants"
17+
},
18+
{
19+
"include": "#variables"
20+
},
21+
{
22+
"include": "#functions"
23+
},
24+
{
25+
"include": "#operators"
26+
}
27+
],
28+
"repository": {
29+
"strings": {
30+
"patterns": [
31+
{
32+
"begin": "\"",
33+
"beginCaptures": {
34+
"1": {
35+
"name": "punctuation.definition.string.begin.pine"
36+
}
37+
},
38+
"end": "\"",
39+
"endCaptures": {
40+
"1": {
41+
"name": "punctuation.definition.string.end.pine"
42+
}
43+
},
44+
"name": "string.quoted.double.pine",
45+
"patterns": [
46+
{
47+
"match": "\\\\.",
48+
"name": "constant.character.escaped.pine"
49+
}
50+
]
51+
},
52+
{
53+
"begin": "'",
54+
"beginCaptures": {
55+
"1": {
56+
"name": "punctuation.definition.string.begin.pine"
57+
}
58+
},
59+
"end": "'",
60+
"endCaptures": {
61+
"1": {
62+
"name": "punctuation.definition.string.end.pine"
63+
}
64+
},
65+
"name": "string.quoted.single.pine",
66+
"patterns": [
67+
{
68+
"match": "\\\\.",
69+
"name": "constant.character.escaped.pine"
70+
}
71+
]
72+
}
73+
]
74+
},
75+
"keywords": {
76+
"patterns": [
77+
{
78+
"match": "\\b(if|else|continue|break|for|return)\\b",
79+
"name": "keyword.control.pine"
80+
}
81+
]
82+
},
83+
"constants": {
84+
"patterns": [
85+
{
86+
"match": "\\b(adjustment|barmerge|barstate|currency|color|format|location|scale|session|shape|size|strategy|syminfo)\\b(?!\\()(?=\\.)",
87+
"name": "support.class.pine"
88+
},
89+
{
90+
"match": "\\b(risk|commission|direction|oca)\\b(?!\\()(?=\\.)",
91+
"name": "support.class.pine"
92+
},
93+
{
94+
"match": "\\b(true|false)\\b(?!\\()",
95+
"name": "constant.language.pine"
96+
},
97+
{
98+
"match": "\\b(open|high|low|close|volume|na|len|period)\\b(?!\\()",
99+
"name": "constant.language.pine"
100+
},
101+
{
102+
"match": "\\b(monday|tuesday|wednesday|thursday|friday|saturday|sunday|second|minute|hour|month|dayofweek|dayofmonth|weekofyear|year)\\b(?!\\()",
103+
"name": "constant.language.pine"
104+
},
105+
{
106+
"match": "\\b(line|linebr|histogram|cross|area|areabr|columns|circles)\\b(?!\\()",
107+
"name": "constant.language.pine"
108+
},
109+
{
110+
"match": "\\bis(daily|dwm|intraday|minutes|monthly|seconds|weekly)?\\b(?!\\()",
111+
"name": "constant.language.pine"
112+
},
113+
{
114+
"match": "\\b(string|symbol|bool|integer|float)\\b(?!\\()",
115+
"name": "constant.language.pine"
116+
},
117+
{
118+
"match": "\\b(dotted|dashed)\\b(?!\\()",
119+
"name": "constant.language.pine"
120+
},
121+
{
122+
"match": "\\b(aqua|black|silver|gray|white|maroon|red|purple|fuchsia|green|lime|olive|yellow|navy|blue|teal|orange)\\b(?!\\()",
123+
"name": "constant.language.pine"
124+
},
125+
{
126+
"match": "\\b(accdist|hl2|hlc3|interval|n|ohlc4|resolution|session|solid|source|stepline|ticker|tickerid|time|timenow|tr|vwap)\\b(?!\\()",
127+
"name": "constant.language.pine"
128+
},
129+
{
130+
"match": "\\b(dividends|none|splits|gaps_off|gaps_on|lookahead_off|lookahead_on|isconfirmed|isfirst|ishistory|islast|isnew|isrealtime|AUD|CAD|CHF|EUR|GBP|HKD|JPY|NOK|NONE|NZD|RUB|SEK|SGD|TRY|USD|ZAR|abovebar|absolute|belowbar|bottom|top|left|right|extended|regular|arrowdown|arrowup|circle|diamond|flag|labeldown|labelup|square|triangledown|triangleup|xcross|auto|huge|large|normal|small|tiny|cash|closedtrades|cash_per_contract|cash_per_order|percent|price|all|long|short|equity|eventrades|fixed|grossloss|grossprofit|initial_capital|losstrades|max_contracts_held_all|max_contracts_held_long|max_contracts_held_short|max_drawdown|netprofit|cancel|reduce|openprofit|opentrades|percent_of_equity|position_avg_price|position_entry_name|position_size|wintrades|mintick|pointvalue|prefix|root|timezone)\\b(?!\\()",
131+
"name": "constant.language.pine"
132+
},
133+
{
134+
"match": "\\b([0-9]+)\\b",
135+
"name": "constant.numeric.pine"
136+
},
137+
{
138+
"match": "#[a-fA-F0-9]{6}",
139+
"name": "contstant.other.pine"
140+
}
141+
]
142+
},
143+
"variables": {
144+
"patterns": [
145+
{
146+
"match": "[a-zA-Z_][a-zA-Z0-9_]*\\s*(?=\\=)",
147+
"name": "variable.other.pine"
148+
}
149+
]
150+
},
151+
"functions": {
152+
"patterns": [
153+
{
154+
"match": "\\b(abs|acros|alertcondition|alma|asin|atan|atr|avg|barcolor|barssince|bgcolor|cci|ceil|change|cog|color|correlation|cos|cross|crossover|crossunder|cum|dayofmonth|dayofweek|dev|ema|exp|falling|fill|fixnan|floor|heikinashi|highest|highestbars|hline|hour|iff|input|kagi|linebreak|linreg|log|log10|lowest|lowestbars|macd|max|min|minute|mom|month|na|nz|offset|percentile_linear_interpolation|percentile_nearest_rank|percentrank|pivothigh|pivotlow|plot(arrow|bar|candle|char|shape)?|pointfigure|pow|renko|rising|rma|roc|round|rsi|sar|second|security|sign|sin|sma|sqrt|stdev|stoch|strategy|cancel|cancel_all|close|close_all|entry|exit|order|allow_entry_in|max_cons_loss_days|max_intraday_filled_orders|max_intraday_loss|max_position_size|study|sum|swma|tan|tickerid|time|timestamp|tostring|tr|tsi|valuewhen|variance|vwap|vwma|weekofyear|wma|year)+?(?=\\()",
155+
"name": "entity.name.function.pine"
156+
},
157+
{
158+
"match": "([a-zA-Z_][a-zA-Z0-9_]*)\\(.*\\)\\s(=>)\\s",
159+
"captures": {
160+
"1": {
161+
"name": "support.function.pine"
162+
},
163+
"2": {
164+
"name": "keyword.operator.assignment.pine"
165+
}
166+
}
167+
}
168+
]
169+
},
170+
"operators": {
171+
"patterns": [
172+
{
173+
"match": "(\\-|\\+|\\*|/|%)",
174+
"name": "keyword.operator.arithmetic.pine"
175+
},
176+
{
177+
"match": "(==|!=|<=|>=|<|>)",
178+
"name": "keyword.operator.comparison.pine"
179+
},
180+
{
181+
"match": "(\\?|\\:)",
182+
"name": "keyword.operator.ternary.pine"
183+
},
184+
{
185+
"match": "\\b(and|or|not)\\b",
186+
"name": "keyword.operator.logical.pine"
187+
},
188+
{
189+
"match": "=",
190+
"name": "keyword.operator.assignment.pine"
191+
}
192+
]
193+
}
194+
},
195+
"scopeName": "source.pine"
196+
}

test/example.pine

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//@version=4
2+
study(title="Bollinger Bands Width", shorttitle="BBW", format=format.price, precision=2)
3+
length = input(20, minval=1)
4+
src = input(close, title="Source")
5+
mult = input(2.0, minval=0.001, maxval=50)
6+
basis = sma(src, length)
7+
dev = mult * stdev(src, length)
8+
upper = basis + dev
9+
lower = basis - dev
10+
bbw = (upper-lower)/basis
11+
plot(bbw, color=color.blue)

0 commit comments

Comments
 (0)