From b906f01e0dee4015cd37e11e75cc2d898112a6fa Mon Sep 17 00:00:00 2001 From: Dan Bornstein Date: Wed, 18 Oct 2023 10:49:34 -0700 Subject: [PATCH 1/4] Add scope definition for `ansi_c_string` in the modern tree-sitter setup. This is how `tree-sitter-bash` marks `$'...'` strings. --- .../language-shellscript/grammars/tree-sitter/highlights.scm | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/language-shellscript/grammars/tree-sitter/highlights.scm b/packages/language-shellscript/grammars/tree-sitter/highlights.scm index 2f914eac3c..bd83554463 100644 --- a/packages/language-shellscript/grammars/tree-sitter/highlights.scm +++ b/packages/language-shellscript/grammars/tree-sitter/highlights.scm @@ -68,6 +68,7 @@ (string "\"" @punctuation.definition.string.end.shell (#is? test.last true)) (raw_string) @string.quoted.single.shell +(ansi_c_string) @string.quoted.single.shell (string (command_substitution) @meta.embedded.line.subshell.shell) From 7189edca8e06b090c42152c105edf72e6355d1c2 Mon Sep 17 00:00:00 2001 From: Dan Bornstein Date: Wed, 18 Oct 2023 12:14:28 -0700 Subject: [PATCH 2/4] Add punctuation matching for `$'...'` strings. --- .../grammars/tree-sitter/highlights.scm | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/language-shellscript/grammars/tree-sitter/highlights.scm b/packages/language-shellscript/grammars/tree-sitter/highlights.scm index bd83554463..4bd5d857c0 100644 --- a/packages/language-shellscript/grammars/tree-sitter/highlights.scm +++ b/packages/language-shellscript/grammars/tree-sitter/highlights.scm @@ -69,6 +69,12 @@ (#is? test.last true)) (raw_string) @string.quoted.single.shell (ansi_c_string) @string.quoted.single.shell +((ansi_c_string) @punctuation.definition.string.begin.shell + (#match? @punctuation.definition.string.begin.shell "^..") + (#set! adjust.startAndEndAroundFirstMatchOf "^..")) +((ansi_c_string) @punctuation.definition.string.end.shell + (#match? @punctuation.definition.string.end.shell ".$") + (#set! adjust.startAndEndAroundFirstMatchOf ".$")) (string (command_substitution) @meta.embedded.line.subshell.shell) From d5249e467890b435e4d2a4178284b08cbc9d27fe Mon Sep 17 00:00:00 2001 From: Dan Bornstein Date: Wed, 18 Oct 2023 12:15:36 -0700 Subject: [PATCH 3/4] Add punctuation matching for `'...'` strings. --- .../grammars/tree-sitter/highlights.scm | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/language-shellscript/grammars/tree-sitter/highlights.scm b/packages/language-shellscript/grammars/tree-sitter/highlights.scm index 4bd5d857c0..d33562dfb6 100644 --- a/packages/language-shellscript/grammars/tree-sitter/highlights.scm +++ b/packages/language-shellscript/grammars/tree-sitter/highlights.scm @@ -68,6 +68,12 @@ (string "\"" @punctuation.definition.string.end.shell (#is? test.last true)) (raw_string) @string.quoted.single.shell +((raw_string) @punctuation.definition.string.begin.shell + (#match? @punctuation.definition.string.begin.shell "^.") + (#set! adjust.startAndEndAroundFirstMatchOf "^.")) +((raw_string) @punctuation.definition.string.end.shell + (#match? @punctuation.definition.string.begin.shell ".$") + (#set! adjust.startAndEndAroundFirstMatchOf ".$")) (ansi_c_string) @string.quoted.single.shell ((ansi_c_string) @punctuation.definition.string.begin.shell (#match? @punctuation.definition.string.begin.shell "^..") From f5162b4653c31bbd9ed9374fe16bb59d51f12c3b Mon Sep 17 00:00:00 2001 From: Dan Bornstein Date: Thu, 19 Oct 2023 15:09:48 -0700 Subject: [PATCH 4/4] Update packages/language-shellscript/grammars/tree-sitter/highlights.scm Co-authored-by: Andrew Dupont --- .../language-shellscript/grammars/tree-sitter/highlights.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/language-shellscript/grammars/tree-sitter/highlights.scm b/packages/language-shellscript/grammars/tree-sitter/highlights.scm index d33562dfb6..505d178c86 100644 --- a/packages/language-shellscript/grammars/tree-sitter/highlights.scm +++ b/packages/language-shellscript/grammars/tree-sitter/highlights.scm @@ -74,7 +74,7 @@ ((raw_string) @punctuation.definition.string.end.shell (#match? @punctuation.definition.string.begin.shell ".$") (#set! adjust.startAndEndAroundFirstMatchOf ".$")) -(ansi_c_string) @string.quoted.single.shell +(ansi_c_string) @string.quoted.single.dollar.shell ((ansi_c_string) @punctuation.definition.string.begin.shell (#match? @punctuation.definition.string.begin.shell "^..") (#set! adjust.startAndEndAroundFirstMatchOf "^.."))