Skip to content

Commit

Permalink
Merge pull request #8 from dgehlich/fix-dollar-quotes-multiline
Browse files Browse the repository at this point in the history
Improved dollar quotes for multiline support
  • Loading branch information
tkopets authored Mar 24, 2020
2 parents 8321a50 + 5fddb45 commit 5b1dce2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
9 changes: 4 additions & 5 deletions PostgreSQL.YAML-tmLanguage
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ repository:
dollar_quotes:
patterns:
- comment: "Assume multiline dollar quote is SQL body!
Start if double dollar quote is followed by no dollar quote till line ending.
Start if double dollar quote is followed by comment (-- or /**/) or linebreak (\n or \r).
See match for dollar quotes as string: string.unquoted.dollar.pgsql.
This could easily support other PL languages like PHP and Ruby -- see PHP heredoc as an example."
# name: meta.dollar-quote.pgsql
contentName: meta.dollar-quote.pgsql
begin: (\$[\w_]*\$)(?=[^\$]*$)
begin: (\$[\w_]*\$)(?=\s*[-\/\n\r]+)
beginCaptures:
'1': {name: punctuation.dollar-quote.begin.pgsql}
end: \1
Expand Down Expand Up @@ -191,9 +191,8 @@ repository:
- comment: Double quoting treated like strings, but they are really identifiers.
name: variable.other.pgsql
match: (")[^"#]*(")
- comment: "Color dollar double quotes as a string if in one line.
No multiline supported because function body is with dollar quotes,
see meta.dollar-quote.pgsql."
- comment: "Color double dollar quotes as a string
Only if not followed by comment or linebreak, see meta.dollar-quote.pgsql."
name: string.unquoted.dollar.pgsql
begin: (\$[\w_]*\$)
end: \1
Expand Down
8 changes: 5 additions & 3 deletions PostgreSQL.tmLanguage
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
<array>
<dict>
<key>begin</key>
<string>(\$[\w_]*\$)(?=[^\$]*$)</string>
<string>(\$[\w_]*\$)(?=\s*[-\/\n\r]+)</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
Expand All @@ -105,7 +105,9 @@
</dict>
</dict>
<key>comment</key>
<string>Assume multiline dollar quote is SQL body! Start if double dollar quote is followed by no dollar quote till line ending. See match for dollar quotes as string: string.unquoted.dollar.pgsql. This could easily support other PL languages like PHP and Ruby -- see PHP heredoc as an example.</string>
<string>Assume multiline dollar quote is SQL body! Start if double dollar quote is followed by comment (-- or /**/) or linebreak (
or
). See match for dollar quotes as string: string.unquoted.dollar.pgsql. This could easily support other PL languages like PHP and Ruby -- see PHP heredoc as an example.</string>
<key>contentName</key>
<string>meta.dollar-quote.pgsql</string>
<key>end</key>
Expand Down Expand Up @@ -574,7 +576,7 @@
<key>begin</key>
<string>(\$[\w_]*\$)</string>
<key>comment</key>
<string>Color dollar double quotes as a string if in one line. No multiline supported because function body is with dollar quotes, see meta.dollar-quote.pgsql.</string>
<string>Color double dollar quotes as a string Only if not followed by comment or linebreak, see meta.dollar-quote.pgsql.</string>
<key>end</key>
<string>\1</string>
<key>name</key>
Expand Down

0 comments on commit 5b1dce2

Please sign in to comment.