From c4a240b13196848212f2053dce49905adc317be0 Mon Sep 17 00:00:00 2001 From: Steve Dignam Date: Sun, 5 Apr 2026 23:27:33 -0400 Subject: [PATCH] vscode: improve syntax highlighting grammar - paren select stmts - function names with database specified --- squawk-vscode/syntaxes/pgsql.tmLanguage.json | 145 +++++++++---------- 1 file changed, 69 insertions(+), 76 deletions(-) diff --git a/squawk-vscode/syntaxes/pgsql.tmLanguage.json b/squawk-vscode/syntaxes/pgsql.tmLanguage.json index 946c27ab..6ad19e94 100644 --- a/squawk-vscode/syntaxes/pgsql.tmLanguage.json +++ b/squawk-vscode/syntaxes/pgsql.tmLanguage.json @@ -12,88 +12,16 @@ "include": "#comments" }, { - "begin": "(?i)^\\s*(create)\\s+(or\\s+replace\\s+)?(function|view)\\s+((?:(?:[\\w]+|\".+\")\\.)?(?:[\\w]+|\".+\"))", - "beginCaptures": { - "1": { - "name": "keyword.other.create.pgsql" - }, - "2": { - "name": "keyword.other.pgsql" - }, - "3": { - "name": "keyword.other.pgsql" - }, - "4": { - "name": "entity.name.function.pgsql" - } - }, + "begin": "^", "end": ";\\s*", - "name": "meta.statement.pgsql.create", + "name": "meta.statement.pgsql", "patterns": [ { - "include": "#dollar_quotes" - }, - { - "include": "#comments" - }, - { - "include": "#strings" + "include": "#create_entities" }, { - "include": "#keywords" + "include": "#parens" }, - { - "include": "#misc" - } - ] - }, - { - "begin": "(?i:^\\s*(create)\\s+(aggregate|collation|conversion|database|domain|event trigger|group|(?:unique\\s+)?index|language|operator class|operator|rule|schema|sequence|(?:global\\s+|local\\s+)?(?:temp\\s+|temporary\\s+|unlogged\\s+)?table|tablespace|trigger|type|user|(?:materialized\\s+)?view)\\s+)(if\\s+not\\s+exists\\s+)?((?:(?:[\\w]+|\".+\")\\.)?(?:[\\w]+|\".+\"))", - "beginCaptures": { - "1": { - "name": "keyword.other.create.pgsql" - }, - "2": { - "name": "keyword.other.pgsql" - }, - "3": { - "name": "keyword.other.pgsql" - }, - "4": { - "name": "entity.name.function.pgsql" - } - }, - "end": ";\\s*", - "name": "meta.statement.pgsql.create", - "patterns": [ - { - "include": "#dollar_quotes" - }, - { - "include": "#comments" - }, - { - "include": "#strings" - }, - { - "include": "#keywords" - }, - { - "include": "#misc" - } - ] - }, - { - "begin": "(^\\s*[a-zA-Z]+)", - "beginCaptures": { - "0": { - "name": "keyword.other.pgsql" - } - }, - "comment": "Last update (including keywords below) using postgres 9.3. See classes/Help.php for update method. Testing change below to just assume starting word is a SQL keyword.", - "end": ";\\s*", - "name": "meta.statement.pgsql", - "patterns": [ { "include": "#dollar_quotes" }, @@ -124,6 +52,44 @@ } ], "repository": { + "create_entities": { + "patterns": [ + { + "match": "(?i)\\b(create)\\s+(or\\s+replace\\s+)?(function|view)\\s+((?:(?:[\\w]+|\".+\")\\.){0,2}(?:[\\w]+|\".+\"))", + "captures": { + "1": { + "name": "keyword.other.create.pgsql" + }, + "2": { + "name": "keyword.other.pgsql" + }, + "3": { + "name": "keyword.other.pgsql" + }, + "4": { + "name": "entity.name.function.pgsql" + } + } + }, + { + "match": "(?i)\\b(create)\\s+(aggregate|collation|conversion|database|domain|event\\s+trigger|group|(?:unique\\s+)?index|language|operator\\s+class|operator|rule|schema|sequence|(?:(?:global|local)\\s+)?(?:(?:temp|temporary|unlogged)\\s+)?table|tablespace|trigger|type|user|(?:materialized\\s+)?view)\\s+(if\\s+not\\s+exists\\s+)?((?:(?:[\\w]+|\".+\")\\.){0,2}(?:[\\w]+|\".+\"))", + "captures": { + "1": { + "name": "keyword.other.create.pgsql" + }, + "2": { + "name": "keyword.other.pgsql" + }, + "3": { + "name": "keyword.other.pgsql" + }, + "4": { + "name": "entity.name.function.pgsql" + } + } + } + ] + }, "comments": { "patterns": [ { @@ -155,6 +121,9 @@ "end": "\\1", "name": "meta.dollar-quote.pgsql", "patterns": [ + { + "include": "#parens" + }, { "include": "#dollar_quotes" }, @@ -210,6 +179,30 @@ } ] }, + "parens": { + "begin": "\\(", + "end": "\\)", + "patterns": [ + { + "include": "#parens" + }, + { + "include": "#dollar_quotes" + }, + { + "include": "#comments" + }, + { + "include": "#strings" + }, + { + "include": "#keywords" + }, + { + "include": "#misc" + } + ] + }, "string_escape": { "match": "\\\\.", "name": "constant.character.escape.pgsql"