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

[REQUEST] sh filetype quotation highlighting of subshells #5228

Open
thoughtpatterns opened this issue Sep 5, 2024 · 2 comments
Open

[REQUEST] sh filetype quotation highlighting of subshells #5228

thoughtpatterns opened this issue Sep 5, 2024 · 2 comments

Comments

@thoughtpatterns
Copy link

Feature

The command substitution section of the specification for POSIX shell specifies:

The results of command substitution shall not be processed for further tilde expansion, parameter expansion, command substitution, or arithmetic expansion. If a command substitution occurs inside double-quotes, field splitting and pathname expansion shall not be performed on the results of the substitution.

Currently when syntax highlighting a subshell such as "$(printf "a b c")", the quotation marks will be parsed such that "$(printf " would be quoted, a b c would be unquoted, and ")" would be quoted; the current behavior (to my knowledge) somewhat obscures what is actually quoted.

Would it be possible to show the inside of a quoted subshell as unquoted? For example, "$(printf "a b c")" would show "$( as quoted (outside the subshell), printf as unquoted, "a b c" as quoted (inside the subshell), and )" as quoted (outside the subshell). Thank you!

Usecase

No response

@pjungkamp
Copy link
Contributor

That is a fundamental issue with the current regions highlighter that affects all programming languages with recursive highlighters and substitutions. The only solution I found is to discard the builtin kakoune highlighters all-together and use https://sr.ht/~hadronized/kak-tree-sitter instead.

Some other examples:

  • Python:
# python
l = [ "a", "b", "c" ]
print(f"string { "|".join(l) }") # <---
let l = [ "a", "b", "c" ]
console.log(`${ l.join(`|`) }`) # <---
# nix
let l = [ "a" "b" "c" ];
in "${ lib.concatStringsSep "|" l }" # <---

@alexherbo2
Copy link
Contributor

If you define the subshell region it should be possible no ?

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

No branches or pull requests

3 participants