Nvim-treesitter: zsh support (need a parser of its own)

Created on 15 Nov 2020  路  5Comments  路  Source: nvim-treesitter/nvim-treesitter

Language informations

Add a zshrc language support, current syntax highlighting is good , but it's not beautiful , I'd rather keywords be red ....

enhancement good first issue help wanted

Most helpful comment

as @theHamsta said i believe someone should write a zsh parser, because the bash parser is crashing all over the place with zsh files.

All 5 comments

Currently, zsh used bash syntax highlighting. There might be differences. Look at queries/bash/highlights.scm

There's a lot of stuff that's broken thanks to some features of zsh syntax (especially with globs). Here's a few lines that caused a lot of errors for me:

[[ $COLORTERM = *(24bit|truecolor)* ]] || zmodload zsh/nearcolor

[[ -n $ZDOTDIR/.zcompdump(#qN.mh+24) ]] && compinit || compinit -C

zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}

() { : }

zstyle ':completion:*:git:*' user-commands ${${(M)${(k)commands}:#git-*}/git-/}

if [[ -e $ZDOTDIR/.zkbd/${TERM}-${${DISPLAY:t}:-$VENDOR-$OSTYPE} ]] {
  source $ZDOTDIR/.zkbd/$TERM-${${DISPLAY:t}:-$VENDOR-$OSTYPE}
}

if (( $+commands[zoxide] )) eval "$(zoxide init zsh)"

if (( $+commands[pigz] )) alias gzip=pigz gunzip="pigz -d" zcat="pigz -dc"

for element ( "$HOME/bin" "$HOME/.dotnet/tools" ) path[${path[(i)$element]}]=()

You could try to create a zsh parser, you can even import the grammar rules from bash or just fork the bash parser.

When you prefer to not use tree-sitter-bash on zsh you can either overwrite the "used_by" entry bash parser or deactivate tree-sitter for zsh file type.

as @theHamsta said i believe someone should write a zsh parser, because the bash parser is crashing all over the place with zsh files.

Switched to Vim-Polyglot.

Was this page helpful?
0 / 5 - 0 ratings