bash-lsp / bash-language-server

A language server for Bash
MIT License
2.14k stars 123 forks source link

Add `vscode-client` highlighting based on `tree-sitter-bash` #303

Open ghost opened 3 years ago

ghost commented 3 years ago

I'd appreciate if something like git branch --delete patch-1 was highlighted appropriately in VSC. The --delete token would be highlighted as a parameter. The git token would be highlighted as a function.

Sample file: https://raw.githubusercontent.com/xtnm/AU-AD/80e8ac1/AE-go_GameServer/check_xml.sh

ghost commented 3 years ago

There seems to be some strange bug in the VSC extension itself that's preventing this highlight.

I'll open an issue at their repository instead.

ghost commented 3 years ago

It's out of VSC's scope. The problem is that this extension doesn't contribute any highlighting.

@mads-hartmann @skovhus could this extension contribute the highlighting tokens defined in:

https://github.com/atom/language-shellscript/blob/685a8b1/grammars/tree-sitter-bash.cson#L75-L144

ghost commented 3 years ago

The scopes that are highlighted exclusively by tree-sitter-bash:

scopes:
  'string > command_substitution': 'embedded.source'
  'command_name': 'entity.name.function'
  'file_descriptor': 'constant.numeric'
  'test_operator': 'entity.other.attribute-name'
  'word': [{match: '^-', scopes: 'entity.other.attribute-name'}]
  'special_variable_name': 'variable.other.member'
  'variable_name': 'variable.other.member'
mads-hartmann commented 3 years ago

@SNDST00M I believe that we'd need to implement semantic highlighting (see guide) to achieve what you want. I can't personally dedicate the time to implement this at the moment but I'm happy to review PRs ☺️