Skip to content
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

Change shellsession grammar or shellscript grammar source for more accurate parsing #43

Closed
Robot-Inventor opened this issue Mar 11, 2024 · 2 comments

Comments

@Robot-Inventor
Copy link

Robot-Inventor commented Mar 11, 2024

This issue is related to a problem with the first command in shellsession not being highlighted correctly (shikijs/shiki#616)

I reported the above issue upstream (jeff-hykin/better-shell-syntax#79) and found that fixing this issue requires action in this repository, so here I am.

First, from a maintenance standpoint, I was told that it would be difficult to update the shellscript grammar to fix the issue. Also, the original shellsession grammar assumes that the grammar file in linguist is used to parse shellscript, not better-shell-syntax used in VS Code. If linguist is used to parse shellscript, shellsession will work correctly.

Therefore, there are two ways to fix this issue.

  1. use linguist instead of better-shell-syntax as the shellscript grammar
  2. fork the better-shell-syntax and shellscript grammars and modify each

I have confirmed that both options will fix the issue. The easiest to work with is option 1, but the possibility of breaking compatibility with other grammars cannot be ruled out. I would like to hear your opinion on this matter.

PS: It seems that only a very few commands are highlighted when linguist is used. Therefore, option 2 may be better if you do not consider the hassle.

@antfu
Copy link
Member

antfu commented Mar 12, 2024

Thanks for your effort in investigating and reporting. Unfortunately, neither of the options seems considerable to me. I think it's easier for Shiki to align with VS Code as much as possible (so we could count on the VS Code team to make sure the grammars are up to date and well maintained).

It would be hard to take immediate action about grammar on our side, as Shiki is about the highlighter, and we can't take care of all grammar for different languages.

I suggest you forget about the grammars Shiki has builtin for a moment. Instead you could provide your own grammars as documented https://shiki.style/guide/load-lang, to use another grammar one or fork your own - until VS Code fixes it and get synced down to Shiki.

Thank you.

@antfu antfu closed this as not planned Won't fix, can't repro, duplicate, stale Mar 12, 2024
@Robot-Inventor
Copy link
Author

Thank you for your kind response. I will use custom grammar.

For others who are interested in this issue: I created a project that automatically patches the VS Code grammar to generate a custom grammar for shellsession. If you need it, you can use it from here: https://github.com/Robot-Inventor/shell-session-syntax/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants