jeff-hykin / better-shell-syntax

💾 📦 ♻️ An improvement to the shell syntax for VS Code
MIT License
52 stars 4 forks source link

JSON embedding #100

Open RedCMD opened 2 months ago

RedCMD commented 2 months ago

The code with a problem is:

"scripts": {
    "watch": "tsc -watch -p ./"
},

It looks like:

image

It should look like:

image workaround is to place a semicolon ; at the start: image

Context

I've created a small extension to embed ShellScript into package.json "scripts" https://marketplace.visualstudio.com/items?itemName=RedCMD.json-embedded-languages however, this ShellScript doesn't like being included directly after a double quote "

from having a quick look, it seems to be as simple as adding " OR \\G OR "\\G to (?<=^|;|\\||&|!|\\(|\\{|\\`) under "normal_statement" https://github.com/jeff-hykin/better-shell-syntax/blob/02b319d961f1396b35981139d38c572134806cb5/autogenerated/shell.tmLanguage.json#L1805 I've added a \\G if need be https://github.com/RedCMD/JSON-Embedded-Languages/blob/51b633515b0f7721bfd763cd8dc2c37e35f5a4a1/syntaxes/package.json.tmLanguage.json#L59-L62

Also... because its embedded in JSON, all double quotes " need to be escaped \" not sure how easy it'll be to address; without simply just supplying a secondary grammar I have something basic working, prob should add backtick-interpolation aswell https://github.com/RedCMD/JSON-Embedded-Languages/commit/dc073598cf17df6ba31a3b9ffe4d6623d78f4ab6

jeff-hykin commented 2 months ago

The \G might not break anything (AKA it might be okay)

I think " would break things.

As for escapes... yeah I think that would require a second grammar