Skip to content

Commit bbea930

Browse files
authored
Merge pull request #17 from kaigouthro/main
Syntax Fully Rescoped, New Themes, Better Completions
2 parents 9a2139b + 3dfb691 commit bbea930

File tree

12 files changed

+2099
-1565
lines changed

12 files changed

+2099
-1565
lines changed

package.json

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
"TradingView" ,
2929
"TradingView.com"
3030
],
31-
"activationEvents": [
31+
"maintainers": [
32+
{ "name": "kai gouthro" }
3233
],
3334
"icon": "media/PineLogo.png",
3435
"capabilities": {
@@ -49,24 +50,26 @@
4950
"main": "./dist/extension.js",
5051
"contributes": {
5152
"themes": [
52-
{ "label": "Pine-*Preferred" , "id": "Dark Theme (*Preferred)" , "uiTheme": "vs-dark", "path": "themes/Pine-Preferred.json" },
53-
{ "label": "Pine-Original-Dark", "id": "Dark Theme (Original)" , "uiTheme": "vs-dark", "path": "themes/Pine-Original.json" },
54-
{ "label": "Pine-V4-Classic" , "id": "Dark V4 Theme (Deep Coverage)", "uiTheme": "vs-dark", "path": "themes/Pine-classic-v4.json" },
55-
{ "label": "Pine-Basic" , "id": "Dark Theme (Basic)" , "uiTheme": "vs-dark", "path": "themes/Pine-Basic.json" },
56-
{ "label": "Pine-Universal" , "id": "Dark Theme (Universal)" , "uiTheme": "vs-dark", "path": "themes/Pine-Universal.json" },
57-
{ "label": "Pine-Cold" , "id": "Dark Theme (Cold)" , "uiTheme": "vs-dark", "path": "themes/Pine-Cold.json" },
58-
{ "label": "Pine-Cool" , "id": "Dark Theme (Cool)" , "uiTheme": "vs-dark", "path": "themes/Pine-Cool.json" },
59-
{ "label": "Pine-Dark #01" , "id": "Dark Theme (#1)" , "uiTheme": "vs-dark", "path": "themes/Pine-Dark#01.json" },
60-
{ "label": "Pine-Dark #02" , "id": "Dark Theme (#2)" , "uiTheme": "vs-dark", "path": "themes/Pine-Dark#02.json" },
61-
{ "label": "Pine-Dark #03" , "id": "Dark Theme (#3)" , "uiTheme": "vs-dark", "path": "themes/Pine-Dark#03.json" },
62-
{ "label": "Pine-Dark #04" , "id": "Dark Theme (#4)" , "uiTheme": "vs-dark", "path": "themes/Pine-Dark#04.json" },
63-
{ "label": "Pine-Dark #05" , "id": "Dark Theme (#5)" , "uiTheme": "vs-dark", "path": "themes/Pine-Dark#05.json" },
64-
{ "label": "Pine-Dark #06" , "id": "Dark Theme (#6)" , "uiTheme": "vs-dark", "path": "themes/Pine-Dark#06.json" },
65-
{ "label": "Pine-Dark #07" , "id": "Dark Theme (#7)" , "uiTheme": "vs-dark", "path": "themes/Pine-Dark#07.json" },
66-
{ "label": "Pine-Dark #08" , "id": "Dark Theme (#8)" , "uiTheme": "vs-dark", "path": "themes/Pine-Dark#08.json" },
67-
{ "label": "Pine-Dark #09" , "id": "Dark Theme (#9)" , "uiTheme": "vs-dark", "path": "themes/Pine-Dark#09.json" },
68-
{ "label": "Pine-Light #01" , "id": "Light Theme (#1)" , "uiTheme": "vs" , "path": "themes/Pine-Light#01.json" },
69-
{ "label": "Pine-Light #02" , "id": "Light Theme (#2)" , "uiTheme": "vs" , "path": "themes/Pine-Light#02.json" }
53+
{ "label": "Pine-*Preferred" , "id": "Dark Theme (*Preferred)" , "uiTheme": "vs-dark", "path": "themes/Pine-Preferred.json" },
54+
{ "label": "Pine-Original-Dark", "id": "Dark Theme (Original)" , "uiTheme": "vs-dark", "path": "themes/Pine-Original.json" },
55+
{ "label": "Pine-V4-Classic" , "id": "Dark V4 Theme (Deep Coverage)", "uiTheme": "vs-dark", "path": "themes/Pine-classic-v4.json" },
56+
{ "label": "Pine-Cadbury" , "id": "Dark Bunny Theme (Deep Coverage)", "uiTheme": "vs-dark", "path": "themes/Pine-Cadbury.json" },
57+
{ "label": "Pine-1980" , "id": "Dark TMNT Theme (Deep Coverage)", "uiTheme": "vs-dark", "path": "themes/Pine-1980.json" },
58+
{ "label": "Pine-Basic" , "id": "Dark Theme (Basic)" , "uiTheme": "vs-dark", "path": "themes/Pine-Basic.json" },
59+
{ "label": "Pine-Universal" , "id": "Dark Theme (Universal)" , "uiTheme": "vs-dark", "path": "themes/Pine-Universal.json" },
60+
{ "label": "Pine-Cold" , "id": "Dark Theme (Cold)" , "uiTheme": "vs-dark", "path": "themes/Pine-Cold.json" },
61+
{ "label": "Pine-Cool" , "id": "Dark Theme (Cool)" , "uiTheme": "vs-dark", "path": "themes/Pine-Cool.json" },
62+
{ "label": "Pine-Dark #01" , "id": "Dark Theme (#1)" , "uiTheme": "vs-dark", "path": "themes/Pine-Dark#01.json" },
63+
{ "label": "Pine-Dark #02" , "id": "Dark Theme (#2)" , "uiTheme": "vs-dark", "path": "themes/Pine-Dark#02.json" },
64+
{ "label": "Pine-Dark #03" , "id": "Dark Theme (#3)" , "uiTheme": "vs-dark", "path": "themes/Pine-Dark#03.json" },
65+
{ "label": "Pine-Dark #04" , "id": "Dark Theme (#4)" , "uiTheme": "vs-dark", "path": "themes/Pine-Dark#04.json" },
66+
{ "label": "Pine-Dark #05" , "id": "Dark Theme (#5)" , "uiTheme": "vs-dark", "path": "themes/Pine-Dark#05.json" },
67+
{ "label": "Pine-Dark #06" , "id": "Dark Theme (#6)" , "uiTheme": "vs-dark", "path": "themes/Pine-Dark#06.json" },
68+
{ "label": "Pine-Dark #07" , "id": "Dark Theme (#7)" , "uiTheme": "vs-dark", "path": "themes/Pine-Dark#07.json" },
69+
{ "label": "Pine-Dark #08" , "id": "Dark Theme (#8)" , "uiTheme": "vs-dark", "path": "themes/Pine-Dark#08.json" },
70+
{ "label": "Pine-Dark #09" , "id": "Dark Theme (#9)" , "uiTheme": "vs-dark", "path": "themes/Pine-Dark#09.json" },
71+
{ "label": "Pine-Light #01" , "id": "Light Theme (#1)" , "uiTheme": "vs" , "path": "themes/Pine-Light#01.json" },
72+
{ "label": "Pine-Light #02" , "id": "Light Theme (#2)" , "uiTheme": "vs" , "path": "themes/Pine-Light#02.json" }
7073
],
7174
"configuration": {},
7275
"submenus": [ { "id": "pine.mysubmenuNonPineFile", "label": " Pine Script v5" }, { "id": "pine.mysubmenu2", "label": " Pine Script v5" } ],
@@ -89,18 +92,19 @@
8992
"dependencies": {
9093
"debounce" : "^2.1.1" ,
9194
"lodash" : "^4.17.21",
92-
"node-fetch": "^3.3.2"
95+
"node-fetch": "^3.3.2" ,
96+
"vscode" : "^1.1.37"
9397
},
9498
"devDependencies": {
9599
"@types/debounce" : "^1.2.4" ,
96-
"@types/lodash" : "^4.17.7" ,
100+
"@types/lodash" : "^4.17.15",
97101
"@types/node" : "^22.5.4" ,
98102
"@types/source-map-support" : "^0.5.10" ,
99103
"@types/vscode" : "^1.93.0" ,
100104
"@typescript-eslint/eslint-plugin": "^7.0.0" ,
101105
"@typescript-eslint/parser" : "^7.0.0" ,
102106
"@vscode/vsce" : "^3.1.0" ,
103-
"eslint" : "^8.56.0" ,
107+
"eslint" : "^8.0.0" ,
104108
"eslint-config-airbnb" : "^19.0.4" ,
105109
"eslint-config-airbnb-typescript" : "^18.0.0" ,
106110
"eslint-plugin-import" : "^2.30.0" ,
@@ -112,10 +116,11 @@
112116
"source-map-support" : "^0.5.21" ,
113117
"ts-loader" : "^9.5.1" ,
114118
"type-coverage" : "^2.0.0" ,
115-
"typedoc" : "^0.26.11",
116-
"typescript" : "^5.6.0" ,
119+
"typedoc" : "^0.27.7" ,
120+
"typescript" : "^5.7.3" ,
117121
"webpack" : "^5.94.0" ,
118122
"webpack-cli" : "^5.1.4" ,
119123
"xo" : "^0.54.0"
120-
}
124+
},
125+
"packageManager": "[email protected]+sha512.c753b6c3ad7afa13af388fa6d808035a008e30ea9993f58c6663e2bc5ff21679aa834db094987129aa4d488b86df57f7b634981b2f827cdcacc698cc0cfb88af"
121126
}

src/PineCompletionProvider.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export class PineCompletionProvider implements vscode.CompletionItemProvider {
4545
document: vscode.TextDocument,
4646
position: vscode.Position,
4747
token: vscode.CancellationToken,
48-
): Promise<vscode.CompletionItem[] | vscode.CompletionList<vscode.CompletionItem> | null | undefined> {
48+
): Promise<vscode.CompletionItem[] | vscode.CompletionList | null | undefined> {
4949
try {
5050
// Initialize the completion items array
5151
this.completionItems = []
@@ -178,18 +178,18 @@ export class PineCompletionProvider implements vscode.CompletionItemProvider {
178178
const kinds: any = {
179179
Function: vscode.CompletionItemKind.Function,
180180
Method: vscode.CompletionItemKind.Method,
181-
Local: vscode.CompletionItemKind.Class,
182-
Imported: vscode.CompletionItemKind.Class,
183-
Integer: vscode.CompletionItemKind.EnumMember,
181+
Local: vscode.CompletionItemKind.Module,
182+
Imported: vscode.CompletionItemKind.Module,
183+
Integer: vscode.CompletionItemKind.Value,
184184
Color: vscode.CompletionItemKind.Color,
185185
Control: vscode.CompletionItemKind.Keyword,
186186
Variable: vscode.CompletionItemKind.Variable,
187187
Boolean: vscode.CompletionItemKind.EnumMember,
188188
Constant: vscode.CompletionItemKind.Enum,
189-
Type: vscode.CompletionItemKind.TypeParameter,
190-
Annotation: vscode.CompletionItemKind.Snippet,
189+
Type: vscode.CompletionItemKind.Class,
190+
Annotation: vscode.CompletionItemKind.Reference,
191191
Property: vscode.CompletionItemKind.Property,
192-
Parameter: vscode.CompletionItemKind.Struct,
192+
Parameter: vscode.CompletionItemKind.TypeParameter,
193193
Other: vscode.CompletionItemKind.Value,
194194
}
195195
// For each key in the mapping, if the kind includes the key, return the corresponding completion item kind

src/PineLint.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,22 +173,25 @@ export class PineLint {
173173
return true;
174174
}
175175

176-
const regex = /\/\/@version=(\d+)(?:[\s\S]+)(indicator|strategy|library|study)\s*\((?:.*\btitle\s*=)?\s*('[^']*'|"[^"]*")/
176+
const version_statement = /\/\/@version=(\d+)/
177+
const script_statement = /(?:indicator|strategy|library|study)\s*\((?:(?<!['\"].*)\btitle\s*=)?\s*('[^\']*'|"[^\"]*")/
178+
177179
const document = VSCode?._Document();
178180
const replaced = document?.getText().replace(/\r\n/g, '\n');
179181

180182
if (!replaced) {
181183
return false;
182184
}
183185

184-
const match = regex.exec(replaced);
186+
const match = version_statement.exec(replaced);
187+
const namematch = script_statement.exec(replaced);
185188
if (!match || !match[1]) {
186189
return false;
187190
}
188191

189-
if (match) {
190-
if (match[3]) {
191-
PineLint.setFileName(match[3]);
192+
if (namematch) {
193+
if (namematch[1]) {
194+
PineLint.setFileName(namematch[1]);
192195
}
193196
PineLint.version = match[1];
194197

syntaxes/Nonsense.ps

4.47 KB
Binary file not shown.
307 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)