helix-editor / helix

A post-modern modal text editor.
https://helix-editor.com
Mozilla Public License 2.0
33.29k stars 2.47k forks source link

Bash/Zsh syntax highlighting #1914

Closed joezak11 closed 2 years ago

joezak11 commented 2 years ago

Summary

I opened a zsh plugin and noticed that the highlighting was messed up

#                                   v
0="${ZERO:-${${0:#$ZSH_ARGZERO}:-${(%):-%N}}}"

if I remove the % character in (%) the string is highlighted correctly but with that character the start quote gets ignored and anything after the second quote is highlighted as a string. this also affects bash files as it seems there is no zsh specific configuration by default.

Reproduction Steps

I tried this: 1. `hx any.zsh` 2. make a string with `"${(%)}"` or other special characters except `#`, `$`, or `&` I expected this to happen: to highlight the string normally even if it is invalid (although in this case it isn't). Instead, this happened: the start quote is ignored and the end quote is parsed as a start qoute ### Helix log _No response_ ### Platform Linux ### Terminal Emulator wezterm 20220319-142410-0fcdea07 ### Helix Version helix 22.05-dev (a9635659)
archseer commented 2 years ago

Can you try bumping the tree-sitter-bash version and fetch/rebuild grammars? We're a bit behind the latest. If you still get the same issue consider reporting it upstream at https://github.com/tree-sitter/tree-sitter-bash

joezak11 commented 2 years ago

it does work after updating tree-sitter-bash

the-mikedavis commented 2 years ago

Would you mind submitting a PR with the update? You'll need to update the revision here: https://github.com/helix-editor/helix/blob/85c23b31deb73d71bb38264485d728665f151d4a/languages.toml#L405

And make a small modification to runtime/queries/bash/highlights.scm: tree-sitter/tree-sitter-bash@tree-sitter:a8eb5cb...tree-sitter:275effd#diff-d485a982e4