nefrob / vscode-just

VSCode syntax highlighting for just files
https://marketplace.visualstudio.com/items?itemName=nefrob.vscode-just-syntax
MIT License
71 stars 1 forks source link

Allow setting/inferring default syntax inside recipes #28

Open jpfeuffer opened 3 months ago

jpfeuffer commented 3 months ago

Seems like this highlighter does not even highlight variables. Is this intended?

Screenshot 2024-08-14 at 12 37 03
jpfeuffer commented 3 months ago

ah it works if you always set a shebang. Maybe setting a default would be nice.

nefrob commented 3 months ago

The text within recipe blocks without explicit shebangs can contain just syntax like the quiet operator @ or interpolations {{ ... }} that will not necessarily highlight correctly in another language's syntax (ex. bash). As such I'm not sure there is a great solution here.

One option could be to explore making this non-default configurable behavior in the extension settings but I'm not sure if that is possible.

jpfeuffer commented 3 months ago

Hmm although I understand that mixing scripting language syntax highlighting with additional just interpolations is hard, after some research it seems that the default syntax is actually clearly defined as shell https://github.com/casey/just?tab=readme-ov-file#shell. (With just-specific additions, as in any other recipe language).

To make it even more complicated, you can actually set the default shell in just with the "shell" just variable. Not sure if one could parse this in the beginning and set it accordingly.

nefrob commented 3 months ago

Oh interesting I guess that does make this more complicated. Since we're already using shell as the default backtick language maybe making this consistent is a good idea and we forgo any highlighting on just specific syntax.

https://github.com/nefrob/vscode-just/blob/d1f2dc90a5f8dd3c7ffa6a9549c414c0ff73e958/syntaxes/just.tmLanguage.yml#L238

I'm not sure it is possible or performant to parse the shell type from setting at the top of the script but that is definitely something to investigate as well.