Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

ZSH Syntax Highlighting broken (envvars/expansion, string quoting issue) #133

Open
1 task done
robobenklein opened this issue Dec 4, 2018 · 6 comments
Open
1 task done

Comments

@robobenklein
Copy link

Prerequisites

Description

Syntax highlighting breaks with some variable expansions and string quoting.

Steps to Reproduce

Take this sample of code:

prompt_p10k_setup () {
  prompt_opts=( cr percent sp subst )
  setopt noprompt{cr,percent,sp,subst} "prompt${^prompt_opts[@]}"

  builtin autoload -Uz _p10k_tracked_autoload add-zsh-hook
  _p10k_tracked_autoload p10k_render_prompt_from_spec prompt_p10k_render_to_vars
  _p10k_tracked_autoload _p10k_define_hook _p10k_add_hook _p10k_run_hook

  # association
  typeset -gA p10k_opts _P10K_SEGMENT_DEFAULTS _P10K_ASYNC_STATII
  # array
  typeset -ga p10k_left p10k_right
}

Expected behavior: [What you expect to happen]

Syntax highlighting past ${^abc} should continue normally.

Actual behavior: [What actually happens]

Safe mode screenshot:
image

Reproduces how often: [What percentage of the time does it reproduce?]

Always.

Versions

Seems to have changed in Atom 1.32 or 1.33, didn't see a problem before that.

Additional Information

Repository with some sample code for testing the highlighting: https://github.com/robobenklein/p10k

@rsese
Copy link

rsese commented Dec 5, 2018

Thanks for the report! Reproduced on macOS 10.12.6 with 1.35.0-nightly2.

@robobenklein
Copy link
Author

Just another update for Atom 1.34.0: still broken but seemingly in a different way:

image
(source code still from zsh project robobenklein/p10k)

Most of the problem appears around ZSH's variable expansion flags, so perhaps there's an indicator around where the problem lies.

${(t)variable} where (t) is the flag.

@winstliu
Copy link
Contributor

@robobenklein the variable expansion you're describing - is that a feature in regular sh/bash as well?

@robobenklein
Copy link
Author

I don't think bash or sh have variable expansion flags like this.

@jspv
Copy link

jspv commented May 7, 2020

Hello, any workaround to clue the syntax highlighter to ignore the issue? I have some large zsh scripts using variable expansion and correct highlighting would be really nice.

@stevekm
Copy link

stevekm commented Feb 4, 2022

I see that this issue is from 2018, pretty surprised that it has not been fixed yet especially since zsh is now the default shell on macOS. I am using Atom version 1.58 on macOS and the syntax highlighting for shell scripts with zsh breaks after I use the "${(%):-%x}" command. I expected maybe there would be a separate language plugin for zsh but that does not seem to be the case either. Kinda hard to believe that all these macOS Atom users are just living with busted syntax highlighting... is there some solution that has not been mentioned?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants