Skip to content

Commit

Permalink
Fix first ShellScript command
Browse files Browse the repository at this point in the history
  • Loading branch information
RedCMD committed Aug 27, 2024
1 parent ec331a0 commit b7c3447
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 10 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,12 @@

## Features

Syntax Highlighting for ShellScript language within `package.json` `"scripts"`
Syntax Highlighting for ShellScript language within `package.json` `"scripts"`.
![Example `package.json` code](images/Example.png)


## Known Issues

ShellScript doesn't highlight code after double quotes `"` .
Workaround is to place a semicolon `;` at the start of each string.

This extension targets every JSON file, not just `package.json`.
However only a root level `"scripts"` object is affected.

Expand All @@ -20,3 +17,6 @@ However only a root level `"scripts"` object is affected.
## For more information

* The GitHub [Issue](https://github.com/microsoft/vscode/issues/224581) that spawned the idea
* https://github.com/jeff-hykin/better-shell-syntax/issues/100
* [Repository](https://github.com/RedCMD/JSON-Embedded-Languages)
* [Marketplace](https://marketplace.visualstudio.com/items?itemName=RedCMD.json-embedded-languages)
Binary file modified images/Example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 23 additions & 6 deletions syntaxes/package.json.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@
"$schema": "https://raw.githubusercontent.com/RedCMD/TmLanguage-Syntax-Highlighter/main/vscode.tmLanguage.schema.json",
"name": "package.json",
"scopeName": "source.json.package",
"injectionSelector": "L:source.json meta.structure.dictionary.json -meta.embedded.shellscript.json.package -meta.structure.dictionary.value.json -meta.structure.array.json -string -comment",
"injectionSelector": "L:source.json meta.structure.dictionary.json -meta.structure.dictionary.value.json -meta.structure.array.json -string -comment",
"patterns": [
{ "include": "#scripts" }
],
"repository": {
"scripts": {
"begin": "(?=\"scripts\")",
"end": "(?<=,)(?!\\G)|(?=})",
"name": "meta.embedded.shellscript.json.package",
"begin": "(?!\\G)(?<=\"scripts\")(?!})",
"end": "(?<=,)|(?=})",
"patterns": [
{ "include": "source.json#objectkey" },
{
"comment": "the JSON object key",
"include": "source.json#objectkey"
},
{ "include": "source.json#comments" },
{
"comment": "Taken straight from `source.json`",
"begin": ":",
Expand Down Expand Up @@ -58,7 +61,17 @@
"comment": "Setup a `\\G` anchor for ShellScript to use",
"begin": "|",
"end": "(*FAIL)",
"patterns": [ { "include": "source.shell" } ]
"patterns": [
{ "include": "source.shell" },
{
"begin": "(?!^[ \\t]*+$)(?:(?<=^until | until |\\tuntil |^while | while |\\twhile |^elif | elif |\\telif |^else | else |\\telse |^then | then |\\tthen |^do | do |\\tdo |^if | if |\\tif )|(?<=\"\\G|^|;|\\||&|!|\\(|\\{|`))[ \\t]*+(?!nocorrect\\W|nocorrect\\$|function\\W|function\\$|foreach\\W|foreach\\$|repeat\\W|repeat\\$|logout\\W|logout\\$|coproc\\W|coproc\\$|select\\W|select\\$|while\\W|while\\$|pushd\\W|pushd\\$|until\\W|until\\$|case\\W|case\\$|done\\W|done\\$|elif\\W|elif\\$|else\\W|else\\$|esac\\W|esac\\$|popd\\W|popd\\$|then\\W|then\\$|time\\W|time\\$|for\\W|for\\$|end\\W|end\\$|fi\\W|fi\\$|do\\W|do\\$|in\\W|in\\$|if\\W|if\\$)",
"end": "(?=;|\\||&|\\n|\\)|`|\\{|\\}|[ \\t]*#|\\])(?<!\\\\)",
"beginCaptures": { },
"endCaptures": { },
"name": "meta.statement.shell",
"patterns": [ { "include": "source.shell#typical_statements" } ]
}
]
},
{ "include": "source.json#stringcontent" }
]
Expand Down Expand Up @@ -91,6 +104,10 @@
"name": "invalid.illegal.expected-dictionary-separator.json"
}
]
},
{
"match": "[^\\s\\}]",
"name": "invalid.illegal.expected-dictionary-separator.json"
}
]
}
Expand Down

0 comments on commit b7c3447

Please sign in to comment.