Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
wants to merge 4 commits into from

Conversation

91khr
Copy link
Contributor

@91khr 91khr commented Dec 2, 2021

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.

91khr 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
@91khr 91khr closed this Dec 3, 2021
@91khr 91khr reopened this Dec 3, 2021
@CoelacanthusHex
Copy link

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
Copy link

CoelacanthusHex commented Dec 3, 2021

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
@91khr
Copy link
Contributor Author

91khr commented Dec 3, 2021 via email

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