georgewfraser / vscode-tree-sitter

Accurate syntax coloring for VSCode using tree-sitter
MIT License
178 stars 25 forks source link

[Language Request] Bash #4

Open dotiful opened 5 years ago

dotiful commented 5 years ago

It would be cool if you could add support for the Bash language. Default shellscript grammar is terrible

georgewfraser commented 5 years ago

Bash is a bit different than other languages, so it might take slightly more effort to support it properly. Specifically, I think you might need to define some more colors to display bash code correctly:

https://github.com/georgewfraser/vscode-tree-sitter/blob/0825e86e7f14b03fb25a2ea335685fc1f8795882/package.json#L49

The way this extension works is that it colors the easy things like keywords and strings using a simplified TextMate grammar that replaces VSCode's builtin grammar. On every edit, it runs tree-sitter, looks at the parse tree, and colors the tricky parts, like fields, functions, and types.

If you want to take a crack at it, there's instructions for adding languages in README.md

tomaxsas commented 5 years ago

https://marketplace.visualstudio.com/items?itemName=mads-hartmann.bash-ide-vscode this extension uses tree-siiter i think

georgewfraser commented 5 years ago

@dotiful I recently figured out how to get the actual textmate scope colors from the color themes: https://github.com/georgewfraser/vscode-tree-sitter/commit/cf939f64c200d2959f663810c6a2970a3419aa82 so I think this is much more feasible now.

I'm not really a bash expert---can you give me some guidance on what great bash syntax coloring should look like? Even a screenshot from some other tool that does a better job coloring bash, with some commentary, would be super helpful to get started.

dotiful commented 5 years ago

@georgewfraser thanks for the answer. Apologies for the delayed response. I'll give you an example later today