Open vitorgalvao opened 7 months ago
This needs a change to the shebang capturing regex so that we also capture the arguments of the shebang: https://github.com/helix-editor/helix/blob/eef46b1aeda8b7061657622c19867663193ecb4c/helix-core/src/syntax.rs#L2365
Thank you for the context. It seems like an easy fix: removing the last \s
. I can submit a PR for that and the languages.toml
but the new question is if that is desirable? There might be a reason why the \s
was added in the first place.
Or maybe you’d prefer I submit the PR anyway and the conversation continues from there?
It looks like that regex originally came from https://github.com/helix-editor/helix/pull/1001. Seems like it's custom so I don't think it should be a problem to change it
When I changed the regex it didn't seem to work yet. I assume a bit more work in another place is required too (Or I made a mistake)
Some food for thought:
sh -options
is a very common shebang for shell scripts. How do we ensure all variations of sh -whatever
continue to match against sh
while supporting this case?osascript -l Javascript
seems a bit rigid to me if an exact match is required. What if there are extra spaces or additional options?python3
input to a python
configuration. It's fortunate that osascript
has no number at the end, as supporting a hypothetical osascript3 -l Javascript
shebang would generate additional complications.The current shebang strategy seems to be:
I don't see a way for a single regex to cover all of the above cases but I wonder if maybe instead, the shebang matching could have two phases: the exe-name match that operates exactly how it currently does, and then a second step that matches on the arguments:
[[language]]
name = "javascript"
shebangs = ["node", { command = "osascript", arguments = ["-l Javascript"] }]
JavaScript for Automation (JXA) is a companion/alternative to AppleScript available for default on macOS. One can use it in a script with the shebang:
Those are essentially JavaScript files and should be treated as such, but currently (if they don’t have an extension) I have to
:set-language
every time I open one.Following the file in the repo, I edited
languages.toml
to have:But files with that shebang are still not parsed as JavaScript. However, it works if the configuration is instead:
Which isn’t quite right, because files without the
-l JavaScript
are “regular” AppleScript, which Helix doesn’t seem to support at all (but that’s a different issue).So maybe a deeper change would be needed in Helix to support this use case? Is there a workaround I can use in the meantime?