Skip to content

Syntax highlighting seemingly not expanding variable substitutions in aliases #794

Open
@johnsonjh

Description

@johnsonjh

I override vi, vim, and nvim with a local version (if available).

The following is the relevant segments from .zshrc:

export VARERR='Error: Variable is not set.'
export EDITOR="/opt/nvim/bin/nvim"
if [ -x "${EDITOR:-}" ]; then        
    alias   nvim="\${EDITOR:?\${VARERR}}"
    alias    vim="\${EDITOR:?\${VARERR}}"
    alias     vi="\${EDITOR:?\${VARERR}}"
fi  

If the local nvim exists, the alias table is set as so:

» whence -va nvim vim vi
nvim is an alias for ${EDITOR:?${VARERR}}
nvim is /usr/bin/nvim
vim is an alias for ${EDITOR:?${VARERR}}
vim is /usr/bin/vim
vi is an alias for ${EDITOR:?${VARERR}}
vi is /usr/bin/vi

This causes zsh-syntax-highlighting to color vi in red, erroneously.

If the alias is more "conventional", then it works as expected, coloring vi in green:
Screenshot
I apologize in advance if this is not expected to work, or if it has already been reported.

I did a cursory search but did not see a similar issue.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions