-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The first command is not parsed correctly when using from other grammars #79
Comments
Yeah dont worry. I'm pretty sure the guy that implemented Textmate wasn't familiar with Textmate. The reason the first command isn't parsed correctly is because the syntax has to use a bunch of hacks to make anything work. One of those hacks is detecting the start by "looking behind". In normal shell files, at the top level (e.g. not in a comment or if statement etc), a command can only have a few chars come before it (ex: In its current state, changing that behavior would break the normal shell grammar. Ideally when grammar1 tells grammar2 to run on some text, it would make pre-text (like I also made a Docker grammar, which includes a shell grammar. I had to basically fork my own shell grammar, make some small changes, to create a shell-for-docker grammar, then direftly include the shell-for-docker grammar in the docker grammar. Its not great, but there isn't really another option thanks to the crappy parsing engine. |
Thank you for your quick and thoughtful reply. Am I correct in understanding that due to TextMate's specifications, it is not possible to fix this issue without breaking the normal shell syntax? It's pretty tricky not being able to hide the pre-text from subsequent grammars... I'll see what other solutions I can come up with, such as forking the shell syntax. Thank you very much! |
Hard to say its impossible, but it certainly would make the shell syntax harder to maintain.
If you fork, open up the |
Oh and also here's the docs for setting up the project: https://github.com/jeff-hykin/better-shell-syntax/blob/master/documentation/setup.md |
It worked perfectly! Thank you so much for taking the time to provide such detailed instructions. I really appreciate your help. I'm going to close this issue now since the problem has been resolved. |
When you import better-shell-syntax from other grammars using
include
, the first command is not parsed correctly.The issue was originally reported in shikijs/shiki#616 by @sventec. Upon investigation, we found that it is a grammar issue. (I'm not familiar with TextMate so sorry if my thoughts are wrong.)
This problem occurs when better-shell-syntax is included from the
shellsession
grammer. On investigation, theshellsession
grammar does not seem to have the problem.For example, if the following code is passed to the shellsession grammar,
the following code is passed to better-shell-syntax, and the first command
echo -n
is not parsed correctly.echo -n
should be split into multiple tokens as shown in the following image, but is actually processed as a single token.The text was updated successfully, but these errors were encountered: