zsh-users / zsh-syntax-highlighting

Fish shell like syntax highlighting for Zsh.
github.com/zsh-users/zsh-syntax-highlighting
BSD 3-Clause "New" or "Revised" License
19.5k stars 1.32k forks source link

Error with termux and `setopt nocaseglob`, but works on other systems #933

Closed hasezoey closed 11 months ago

hasezoey commented 1 year ago

i have noticed that when trying to use zsh-syntax-highlighting with setopt nocaseglob in termux results in the following error:

zsh-syntax-highlighting: ')' highlighter should define both required functions '_zsh_highlight_highlighter_)_paint' and '_zsh_highlight_highlighter_)_predicate' in '/data/data/com.termux/files/home/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting/highlighters/*/(/))-highlighter.zsh'.
$(build_prompt) zsh-syntax-highlighting: warning: disabling the 'main' highlighter as it has not been loaded

with the same zshrc (with adjusted oh-my-zsh paths) and same zsh-syntax-highlighting version on different systems (manjaro & ubuntu) it just works without errors

zsh 5.9 (aarch64-unknown-linux-android) oh-my-zsh at f5cb9a6c978693c9570206f4267ba2589bef1b4c zsh-syntax-highlighting at 932e29a0c75411cb618f02995b66c0a4a25699bc (0.7.1) and 1386f1213eb0b0589d73cd3cf7c56e6a972a9bfd (current master HEAD)

Edit: the same error happens when using unsetopt CASE_GLOB

Full .zshrc ```zsh export ZSH="/data/data/com.termux/files/home/.oh-my-zsh" # Set ZSH Options setopt correct # Auto correct mistakes setopt nocaseglob # Case insensitive globbing setopt rcexpandparam # Better Expand Array parameters setopt checkjobs # Warn for any background or suspended jobs managed by the current shell setopt numericglobsort # When possible, sort by number and not by alphabet setopt nobeep # Disable any beeps setopt appendhistory # Better history keeping when multiple shell instances are used setopt histignorealldups # Remove old (exact) history entries, and append new one setopt autocd # If only a directory path is ented, interpret it as a "cd" setopt inc_append_history # Write command to history file directly after entering it setopt extended_glob # Allow more patterns with glob # Set ZSH completion behaviour zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' # Case insensitive tab completion zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}" # Colored completion (different colors for dirs/files/etc) zstyle ':completion:*' rehash true # automatically find new executables in path ## Speed up completions zstyle ':completion:*' accept-exact '*(N)' zstyle ':completion:*' use-cache on zstyle ':completion:*' cache-path ~/.zsh/cache # Set ZSH Variables HISTFILE=~/.zsh_history # Set History file location HISTSIZE=1000 # Set the ZSH Command history length to 1k SAVEHIST=1000 # Set something to 1k HIST_STAMPS="dd.mm.yyyy" # Set History file timestamp format WORDCHARS=${WORDCHARS//\/[&.;]} # Don't consider certain characters part of the word ZSH_THEME_TERM_TAB_TITLE_IDLE="%30<..<%~%<<" # Set TAB idle to 30 char left truncated of current PWD ZSH_THEME_TERM_TITLE_IDLE="%n@%m:%~" # no idea ZSH_CACHE_DIR=~/.cache/zsh # Set ZSH cache directory to use the home-cache CASE_SENSITIVE="false" # Change ZSH to be case-insensitive fpath=($ZSH_CUSTOM $fpath) # no idea DISABLE_AUTO_UPDATE="true" # disable oh-my-zsh update checking # ZSH Themeing autoload -U compinit colors zcalc # compinit -d # Init auto-completion of files _comp_options+=(globdots) # Enable ".files" for auto-completions colors # Enable ZSH colors? ZSH_THEME="agnoster" # Set ZSH theme # Set ZSH keybindings bindkey -e bindkey '^[[7~' beginning-of-line # Home key bindkey '^[[H' beginning-of-line # Home key if [[ "${terminfo[khome]}" != "" ]]; then bindkey "${terminfo[khome]}" beginning-of-line # [Home] - Go to beginning of line fi bindkey '^[[8~' end-of-line # End key bindkey '^[[F' end-of-line # End key if [[ "${terminfo[kend]}" != "" ]]; then bindkey "${terminfo[kend]}" end-of-line # [End] - Go to end of line fi bindkey '^[[2~' overwrite-mode # Insert key bindkey '^[[3~' delete-char # Delete key bindkey '^[[C' forward-char # Right key bindkey '^[[D' backward-char # Left key bindkey '^[[5~' history-beginning-search-backward # Page up key bindkey '^[[6~' history-beginning-search-forward # Page down key ## Navigate words with ctrl+arrow keys bindkey '^[Oc' forward-word # bindkey '^[Od' backward-word # bindkey '^[[1;5D' backward-word # bindkey '^[[1;5C' forward-word # bindkey '^H' backward-kill-word # delete previous word with ctrl+backspace bindkey '^[[Z' undo # Shift+tab undo last action export EDITOR="nano" # ZSH Plugins ## Use ohmyzsh plugins=( git git-extras history-substring-search colored-man-pages zsh-syntax-highlighting zsh-autosuggestions ) source $ZSH/oh-my-zsh.sh ```
phy1729 commented 11 months ago

Does changing line 530 in zsh-syntax-highlighting.zsh to

for highlighter_dir ($1/*/(N/)); do

at least make the error disappear?

Are there any directories in /data/data/com.termux/files/home/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting/highlighters ?

hasezoey commented 11 months ago

Are there any directories in /data/data/com.termux/files/home/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting/highlighters ?

yes

$ ls highlighters/*
highlighters/README.md

highlighters/brackets:
README.md  brackets-highlighter.zsh  test-data

highlighters/cursor:
README.md  cursor-highlighter.zsh

highlighters/line:
README.md  line-highlighter.zsh

highlighters/main:
README.md  main-highlighter.zsh  test-data

highlighters/pattern:
README.md  pattern-highlighter.zsh  test-data

highlighters/regexp:
README.md  regexp-highlighter.zsh  test-data

highlighters/root:
README.md  root-highlighter.zsh

at least make the error disappear?

yes, the error is gone, but there are some other problems when setopt nocaseglob (likely not related to this plugin):

but those problem do not happen at all on all my other systems which are not termux (manjaro, linux mint, ubuntu) with the exact same configs and oh-my-zsh install

phy1729 commented 11 months ago

Seems to be due to https://github.com/termux/termux-packages/issues/1894 . Closing this issue as it seems the fix was backported to the termux package and no change is needed in z-sy-h.

hasezoey commented 11 months ago

well as you can see in https://github.com/termux/termux-packages/issues/17485, it is not entirely fixed yet, though yes i also dont think it is this plugins fault