Skip to content

Commit 98d1219

Browse files
authored
vscode: improve syntax highlighting grammar (#1043)
- paren select stmts - function names with database specified <img width="504" height="149" alt="Screenshot 2026-04-05 at 11 26 26 PM" src="https://github.com/user-attachments/assets/3cecf366-e898-49d7-9fe6-f4428b82e935" />
1 parent 5999ed3 commit 98d1219

1 file changed

Lines changed: 69 additions & 76 deletions

File tree

squawk-vscode/syntaxes/pgsql.tmLanguage.json

Lines changed: 69 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -12,88 +12,16 @@
1212
"include": "#comments"
1313
},
1414
{
15-
"begin": "(?i)^\\s*(create)\\s+(or\\s+replace\\s+)?(function|view)\\s+((?:(?:[\\w]+|\".+\")\\.)?(?:[\\w]+|\".+\"))",
16-
"beginCaptures": {
17-
"1": {
18-
"name": "keyword.other.create.pgsql"
19-
},
20-
"2": {
21-
"name": "keyword.other.pgsql"
22-
},
23-
"3": {
24-
"name": "keyword.other.pgsql"
25-
},
26-
"4": {
27-
"name": "entity.name.function.pgsql"
28-
}
29-
},
15+
"begin": "^",
3016
"end": ";\\s*",
31-
"name": "meta.statement.pgsql.create",
17+
"name": "meta.statement.pgsql",
3218
"patterns": [
3319
{
34-
"include": "#dollar_quotes"
35-
},
36-
{
37-
"include": "#comments"
38-
},
39-
{
40-
"include": "#strings"
20+
"include": "#create_entities"
4121
},
4222
{
43-
"include": "#keywords"
23+
"include": "#parens"
4424
},
45-
{
46-
"include": "#misc"
47-
}
48-
]
49-
},
50-
{
51-
"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]+|\".+\"))",
52-
"beginCaptures": {
53-
"1": {
54-
"name": "keyword.other.create.pgsql"
55-
},
56-
"2": {
57-
"name": "keyword.other.pgsql"
58-
},
59-
"3": {
60-
"name": "keyword.other.pgsql"
61-
},
62-
"4": {
63-
"name": "entity.name.function.pgsql"
64-
}
65-
},
66-
"end": ";\\s*",
67-
"name": "meta.statement.pgsql.create",
68-
"patterns": [
69-
{
70-
"include": "#dollar_quotes"
71-
},
72-
{
73-
"include": "#comments"
74-
},
75-
{
76-
"include": "#strings"
77-
},
78-
{
79-
"include": "#keywords"
80-
},
81-
{
82-
"include": "#misc"
83-
}
84-
]
85-
},
86-
{
87-
"begin": "(^\\s*[a-zA-Z]+)",
88-
"beginCaptures": {
89-
"0": {
90-
"name": "keyword.other.pgsql"
91-
}
92-
},
93-
"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.",
94-
"end": ";\\s*",
95-
"name": "meta.statement.pgsql",
96-
"patterns": [
9725
{
9826
"include": "#dollar_quotes"
9927
},
@@ -124,6 +52,44 @@
12452
}
12553
],
12654
"repository": {
55+
"create_entities": {
56+
"patterns": [
57+
{
58+
"match": "(?i)\\b(create)\\s+(or\\s+replace\\s+)?(function|view)\\s+((?:(?:[\\w]+|\".+\")\\.){0,2}(?:[\\w]+|\".+\"))",
59+
"captures": {
60+
"1": {
61+
"name": "keyword.other.create.pgsql"
62+
},
63+
"2": {
64+
"name": "keyword.other.pgsql"
65+
},
66+
"3": {
67+
"name": "keyword.other.pgsql"
68+
},
69+
"4": {
70+
"name": "entity.name.function.pgsql"
71+
}
72+
}
73+
},
74+
{
75+
"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]+|\".+\"))",
76+
"captures": {
77+
"1": {
78+
"name": "keyword.other.create.pgsql"
79+
},
80+
"2": {
81+
"name": "keyword.other.pgsql"
82+
},
83+
"3": {
84+
"name": "keyword.other.pgsql"
85+
},
86+
"4": {
87+
"name": "entity.name.function.pgsql"
88+
}
89+
}
90+
}
91+
]
92+
},
12793
"comments": {
12894
"patterns": [
12995
{
@@ -155,6 +121,9 @@
155121
"end": "\\1",
156122
"name": "meta.dollar-quote.pgsql",
157123
"patterns": [
124+
{
125+
"include": "#parens"
126+
},
158127
{
159128
"include": "#dollar_quotes"
160129
},
@@ -210,6 +179,30 @@
210179
}
211180
]
212181
},
182+
"parens": {
183+
"begin": "\\(",
184+
"end": "\\)",
185+
"patterns": [
186+
{
187+
"include": "#parens"
188+
},
189+
{
190+
"include": "#dollar_quotes"
191+
},
192+
{
193+
"include": "#comments"
194+
},
195+
{
196+
"include": "#strings"
197+
},
198+
{
199+
"include": "#keywords"
200+
},
201+
{
202+
"include": "#misc"
203+
}
204+
]
205+
},
213206
"string_escape": {
214207
"match": "\\\\.",
215208
"name": "constant.character.escape.pgsql"

0 commit comments

Comments
 (0)