Skip to content

Commit d91e18f

Browse files
authored
Merge pull request #52 from fdncred/053_changes
updates
2 parents c664957 + a353010 commit d91e18f

File tree

5 files changed

+78
-44
lines changed

5 files changed

+78
-44
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,7 @@ All notable changes to the "vscode-nushell-lang" extension will be documented in
8989
- 0.5.2
9090
- add `true`, `false`, and `null` as pseudo keywords
9191
- changed the indentation rules
92+
- 0.5.3
93+
- updated language punctuation recognition
94+
- added the ability to recognize block parameters as variables
95+
- split out part of the readme.md into building.md

README.md

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -21,29 +21,6 @@ With Nushell-Light Color Theme
2121

2222
See [our Github repository](https://github.com/nushell/vscode-nushell-lang/issues) for active issues.
2323

24-
## Regex Engine
25-
26-
VSCode uses a regular expressions engine that is based on Ruby for syntax highlighting.
27-
[This is a good site](https://rubular.com/) to test and try out these regular expressions.
28-
29-
## Build Process
30-
31-
We pretty much followed [these instructions](https://code.visualstudio.com/api/get-started/your-first-extension) for building this extension.
32-
And [this link](https://code.visualstudio.com/api/working-with-extensions/publishing-extension) for packaging the extension.
33-
34-
To summarize, the steps were:
35-
36-
1. `npm install -g yo generator-code`
37-
2. `yo code`
38-
3. choose "New Language Support" and fill out the rest of the questions
39-
4. `npm install -g vsce`
40-
5. update the `README.md` and `package.json`
41-
6. `vsce package`
42-
7. `code --install-extension vscode-nushell-lang-0.0.2.vsix`<br/>
43-
(Alternatively, you can do <kbd>Ctrl</kbd>/<kbd>Cmd</kbd>-<kbd>Shift</kbd>-<kbd>P</kbd> and type "Extensions:Install From VSIX...")
44-
45-
If you have all these tools already installed, you should be able to clone this repo and just run `vsce package` to get a `.vsix` file that you can install in vscode.
46-
4724
## Help
4825

4926
We are happily accepting pull requests to make this better. :)

building.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Building
2+
3+
## Regex Engine
4+
5+
VSCode uses a regular expressions engine that is based on Ruby for syntax highlighting.
6+
[This Rubular site is good site](https://rubular.com/) to test and try out these regular expressions because it uses Ruby which supports `oniguruma` flavor of regular expressions.
7+
8+
## Build Process
9+
10+
We pretty much followed [these instructions](https://code.visualstudio.com/api/get-started/your-first-extension) for building this extension.
11+
And [this link](https://code.visualstudio.com/api/working-with-extensions/publishing-extension) for packaging the extension.
12+
13+
To summarize, the steps were:
14+
15+
1. `npm install -g yo generator-code`
16+
2. `yo code`
17+
3. choose "New Language Support" and fill out the rest of the questions
18+
4. `npm install -g vsce`
19+
5. update the `README.md` and `package.json`
20+
6. `vsce package`
21+
7. `code --install-extension vscode-nushell-lang-0.0.2.vsix`<br/>
22+
(Alternatively, you can do <kbd>Ctrl</kbd>/<kbd>Cmd</kbd>-<kbd>Shift</kbd>-<kbd>P</kbd> and type "Extensions:Install From VSIX...")
23+
24+
If you have all these tools already installed, you should be able to clone this repo and just run `vsce package` to get a `.vsix` file that you can install in vscode.
25+
26+
## Regex Engine
27+
28+
TIL - VSCode uses regexes for language syntax highlighting in \*.tmLanguage.json files. Those regexes and json are based on Textmate, which uses (and here is the secret-sauce) `oniguruma` flavor of syntax. See the cheat-sheet for the [syntax here](https://github.com/kkos/oniguruma/blob/master/doc/RE). Also there's a rust-crate called `onig` or `rust-onig` if we wanted to write something to help create compatible regular expressions.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "vscode-nushell-lang",
33
"displayName": "vscode-nushell-lang",
44
"description": "nushell language for vscode",
5-
"version": "0.5.2",
5+
"version": "0.5.3",
66
"preview": true,
77
"license": "MIT",
88
"publisher": "TheNuProjectContributors",

syntaxes/nushell.tmLanguage.json

Lines changed: 45 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,52 @@
177177
"begin": "\"|'|`",
178178
"end": "\"|'|`"
179179
},
180+
"variable": {
181+
"match": "(alias|let|let-env)\\s+[\\$'\"]?([a-z A-Z0-9_-]+)['\"]?|(\\$[a-zA-Z0-9_\\-]+)|(\\|)([$a-zA-Z0-9-]+)[\\s,]+([$a-zA-Z0-9-]+)(\\|)",
182+
"name": "variable.nushell",
183+
"captures": {
184+
"1": { "name": "keyword.other.nushell" },
185+
"2": { "name": "variable.name.nushell" },
186+
"3": { "name": "variable.name.nushell" },
187+
"4": { "name": "punctuation.nushell" },
188+
"5": { "name": "variable.name.nushell" },
189+
"6": { "name": "variable.name.nushell" },
190+
"7": { "name": "punctuation.nushell" }
191+
}
192+
},
180193
"punctuation": {
181-
"match": "(;|\\||\\.|\\[|\\]|\\{|\\}|\\(|\\)|=|\\<|>)|(\\$\\(|\\$\\[|\\+|\\%|\\/|\\*)",
182-
"name": "punctuation.nushell"
194+
"patterns": [
195+
{
196+
"comment": "comma",
197+
"name": "punctuation.comma.nushell",
198+
"match": ","
199+
},
200+
{
201+
"comment": "curly braces",
202+
"name": "punctuation.brackets.curly.nushell",
203+
"match": "[{}]"
204+
},
205+
{
206+
"comment": "parentheses, round brackets",
207+
"name": "punctuation.brackets.round.nushell",
208+
"match": "[()]"
209+
},
210+
{
211+
"comment": "semicolon",
212+
"name": "punctuation.semi.nushell",
213+
"match": ";"
214+
},
215+
{
216+
"comment": "square brackets",
217+
"name": "punctuation.brackets.square.nushell",
218+
"match": "[\\[\\]]"
219+
},
220+
{
221+
"comment": "angle brackets",
222+
"name": "punctuation.brackets.angle.nushell",
223+
"match": "(?<!=)[<>]"
224+
}
225+
]
183226
},
184227
"comment": {
185228
"match": "(#.*)",
@@ -206,24 +249,6 @@
206249
}
207250
}
208251
},
209-
"variable": {
210-
"match": "(alias|let|let-env)\\s+(\\$?[a-zA-Z0-9_\\-]+)|(^[\\[]\\[\\$[a-zA-Z0-9_\\-]+)|(\\$[a-zA-Z0-9_\\-]+)",
211-
"name": "variable.nushell",
212-
"captures": {
213-
"1": {
214-
"name": "keyword.other.nushell"
215-
},
216-
"2": {
217-
"name": "variable.name.nushell"
218-
},
219-
"3": {
220-
"name": "variable.language.nushell"
221-
},
222-
"4": {
223-
"name": "variable.language.nushell"
224-
}
225-
}
226-
},
227252
"function": {
228253
"match": "\\b(def|def-env|extern)\\s+([\"'a-zA-Z0-9_\\- ]{1,})",
229254
"name": "entity.name",

0 commit comments

Comments
 (0)