Skip to content

Divide parentheses into kinds so as to match languages with complex parentheses syntax#175

Closed
senioria wants to merge 4 commits into
luochen1990:masterfrom
senioria:master
Closed

Divide parentheses into kinds so as to match languages with complex parentheses syntax#175
senioria wants to merge 4 commits into
luochen1990:masterfrom
senioria:master

Conversation

@senioria

@senioria senioria commented Dec 2, 2021

Copy link
Copy Markdown
Contributor

Inspired by and thus fixes #174

Some languages like shell (and maybe Agda) have a somehow complex syntax:

(echo hello; echo hi) | cat  # Subshells in single quote
(((1+2)+3-$((6)))); echo $?  # Arithmetic expression

Handling this is not so easy as it seems to be: outside of the arithmetic expression, only single parentheses can be matched, otherwise we can't match the parentheses for the arithmetic expressions, but inside the arithmetic expression, single parentheses should always be matched as-is since the expression can't be nested. In vim's origin design, this is solved by contained etc.; but since Rainbow generates lots of syntax rules to highlight parentheses at different levels, unfortunately vim provides no mechanism to deal with them.

This is one possible approach of solving the problem: bundle different parentheses into 'kind's like vim bundle syntax clusters, so that the parentheses can cascade correctly.

Virginia Senioria added 3 commits December 2, 2021 22:44
and lua long bracket string
and strong in README which cannot be displayed correctly in GitHub
and removed unnecessary kinds
@senioria senioria closed this Dec 3, 2021
@senioria senioria reopened this Dec 3, 2021
@CoelacanthusHex

Copy link
Copy Markdown

Bash and POSIX sh use same parenthese syntax, so these should use same setting.
But I see the author disabled this plugin for ft=sh.
@luochen1990 Is this caused by this syntax? If it is, please use same setting for sh and bash as well.

@CoelacanthusHex

CoelacanthusHex commented Dec 3, 2021

Copy link
Copy Markdown

BTW, POSIX compatible shell like ash and dash (bash and zsh as well) also using same syntax, but csh/tcsh use single parenthese syntax for arithmetic operations and fish use a math built-in command, so csh/tcsh/fish shouldn't use same setting, normal setting is enough for them.

rearranged zsh parentheses highlight
add test case for zsh
@senioria

senioria commented Dec 3, 2021 via email

Copy link
Copy Markdown
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Arithmetic operation using (( xxx )) is rendered wrongly in bash/zsh

2 participants