Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
fdncred committed Mar 30, 2022
1 parent c664957 commit a353010
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 44 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,7 @@ All notable changes to the "vscode-nushell-lang" extension will be documented in
- 0.5.2
- add `true`, `false`, and `null` as pseudo keywords
- changed the indentation rules
- 0.5.3
- updated language punctuation recognition
- added the ability to recognize block parameters as variables
- split out part of the readme.md into building.md
23 changes: 0 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,6 @@ With Nushell-Light Color Theme

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

## Regex Engine

VSCode uses a regular expressions engine that is based on Ruby for syntax highlighting.
[This is a good site](https://rubular.com/) to test and try out these regular expressions.

## Build Process

We pretty much followed [these instructions](https://code.visualstudio.com/api/get-started/your-first-extension) for building this extension.
And [this link](https://code.visualstudio.com/api/working-with-extensions/publishing-extension) for packaging the extension.

To summarize, the steps were:

1. `npm install -g yo generator-code`
2. `yo code`
3. choose "New Language Support" and fill out the rest of the questions
4. `npm install -g vsce`
5. update the `README.md` and `package.json`
6. `vsce package`
7. `code --install-extension vscode-nushell-lang-0.0.2.vsix`<br/>
(Alternatively, you can do <kbd>Ctrl</kbd>/<kbd>Cmd</kbd>-<kbd>Shift</kbd>-<kbd>P</kbd> and type "Extensions:Install From VSIX...")

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.

## Help

We are happily accepting pull requests to make this better. :)
28 changes: 28 additions & 0 deletions building.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Building

## Regex Engine

VSCode uses a regular expressions engine that is based on Ruby for syntax highlighting.
[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.

## Build Process

We pretty much followed [these instructions](https://code.visualstudio.com/api/get-started/your-first-extension) for building this extension.
And [this link](https://code.visualstudio.com/api/working-with-extensions/publishing-extension) for packaging the extension.

To summarize, the steps were:

1. `npm install -g yo generator-code`
2. `yo code`
3. choose "New Language Support" and fill out the rest of the questions
4. `npm install -g vsce`
5. update the `README.md` and `package.json`
6. `vsce package`
7. `code --install-extension vscode-nushell-lang-0.0.2.vsix`<br/>
(Alternatively, you can do <kbd>Ctrl</kbd>/<kbd>Cmd</kbd>-<kbd>Shift</kbd>-<kbd>P</kbd> and type "Extensions:Install From VSIX...")

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.

## Regex Engine

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.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "vscode-nushell-lang",
"displayName": "vscode-nushell-lang",
"description": "nushell language for vscode",
"version": "0.5.2",
"version": "0.5.3",
"preview": true,
"license": "MIT",
"publisher": "TheNuProjectContributors",
Expand Down
65 changes: 45 additions & 20 deletions syntaxes/nushell.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,52 @@
"begin": "\"|'|`",
"end": "\"|'|`"
},
"variable": {
"match": "(alias|let|let-env)\\s+[\\$'\"]?([a-z A-Z0-9_-]+)['\"]?|(\\$[a-zA-Z0-9_\\-]+)|(\\|)([$a-zA-Z0-9-]+)[\\s,]+([$a-zA-Z0-9-]+)(\\|)",
"name": "variable.nushell",
"captures": {
"1": { "name": "keyword.other.nushell" },
"2": { "name": "variable.name.nushell" },
"3": { "name": "variable.name.nushell" },
"4": { "name": "punctuation.nushell" },
"5": { "name": "variable.name.nushell" },
"6": { "name": "variable.name.nushell" },
"7": { "name": "punctuation.nushell" }
}
},
"punctuation": {
"match": "(;|\\||\\.|\\[|\\]|\\{|\\}|\\(|\\)|=|\\<|>)|(\\$\\(|\\$\\[|\\+|\\%|\\/|\\*)",
"name": "punctuation.nushell"
"patterns": [
{
"comment": "comma",
"name": "punctuation.comma.nushell",
"match": ","
},
{
"comment": "curly braces",
"name": "punctuation.brackets.curly.nushell",
"match": "[{}]"
},
{
"comment": "parentheses, round brackets",
"name": "punctuation.brackets.round.nushell",
"match": "[()]"
},
{
"comment": "semicolon",
"name": "punctuation.semi.nushell",
"match": ";"
},
{
"comment": "square brackets",
"name": "punctuation.brackets.square.nushell",
"match": "[\\[\\]]"
},
{
"comment": "angle brackets",
"name": "punctuation.brackets.angle.nushell",
"match": "(?<!=)[<>]"
}
]
},
"comment": {
"match": "(#.*)",
Expand All @@ -206,24 +249,6 @@
}
}
},
"variable": {
"match": "(alias|let|let-env)\\s+(\\$?[a-zA-Z0-9_\\-]+)|(^[\\[]\\[\\$[a-zA-Z0-9_\\-]+)|(\\$[a-zA-Z0-9_\\-]+)",
"name": "variable.nushell",
"captures": {
"1": {
"name": "keyword.other.nushell"
},
"2": {
"name": "variable.name.nushell"
},
"3": {
"name": "variable.language.nushell"
},
"4": {
"name": "variable.language.nushell"
}
}
},
"function": {
"match": "\\b(def|def-env|extern)\\s+([\"'a-zA-Z0-9_\\- ]{1,})",
"name": "entity.name",
Expand Down

0 comments on commit a353010

Please sign in to comment.