diff --git a/README.md b/README.md index 293c432..96570a7 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ Install `python-string-sql` from extensions (`ctrl + shift + x` or `cmd + shift ## Usage -Insert `--sql`, `--beginsql`, or `--begin-sql` at the beginning of the part of the string you would like highlighted and a semicolon, `--endsql`, or `--end-sql` at the end of the highlighted section. +In a `""" multi-line """` or `f""" f-string multiline """` string, use a `select`, `with`, or `-- sql-comment`, and the string will then be treated as embedded SQL. ### Snippets begin typing `sql` and the autocomplete snippet will appear: @@ -25,7 +25,6 @@ begin typing `sql` and the autocomplete snippet will appear: cmd+s (or ctrl+s on mac) - Insert the following snippet: ``` """ ---sql SELECT ; """ diff --git a/docs/demo.png b/docs/demo.png index 8b7036d..57ca4d7 100644 Binary files a/docs/demo.png and b/docs/demo.png differ diff --git a/docs/demo.py b/docs/demo.py index 2d38ec1..a1f1956 100644 --- a/docs/demo.py +++ b/docs/demo.py @@ -4,7 +4,6 @@ cur = conn.cursor() query = """ ---begin-sql SELECT last_name, start_day, COUNT(*) AS num_entries diff --git a/snippets/python.json b/snippets/python.json index 8d3f04f..e94faa5 100644 --- a/snippets/python.json +++ b/snippets/python.json @@ -3,7 +3,6 @@ "prefix": "sql", "body": [ "\"\"\"", - "--sql", "${1| ,SELECT,WITH|}", ";", "\"\"\"" diff --git a/syntaxes/highlight-sql-string.json b/syntaxes/highlight-sql-string.json index 50ad41e..85ed1fb 100644 --- a/syntaxes/highlight-sql-string.json +++ b/syntaxes/highlight-sql-string.json @@ -5,19 +5,17 @@ "injectionSelector": "L:string.quoted.multi.python, L:meta.fstring.python - (comment.line.number-sign.python, punctuation.definition.comment.python)", "patterns": [ { - "begin": "( *--sql| *--beginsql| *--begin-sql)", - "end": "( *;| *--endsql| *--end-sql)", - "captures": { - "1": { - "name": "variable.parameter" - } + "name": "meta.embedded.sql", + "begin": "\\s*((?i)(select|with)|(--.*))", + "end": "(?=\"\"\")", + "beginCaptures": { + "2": { "name": "keyword.other.DML.sql" }, + "3": { "name": "comment.line.double-dash.sql" } }, "patterns": [ - { - "include": "source.sql" - } + { "include": "source.sql" } ] } ], "scopeName": "python-sql.injection" -} \ No newline at end of file +}