Skip to content

Commit bf83441

Browse files
azizkprincemaple
authored andcommitted
SQL: match function calls, scalars and decimal numbers.
* Removed support.function.psql capture group to keep it simple.
1 parent 08d8b77 commit bf83441

File tree

1 file changed

+33
-39
lines changed

1 file changed

+33
-39
lines changed

SQL (Elixir).sublime-syntax

Lines changed: 33 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -8,37 +8,23 @@ contexts:
88
main:
99
- match: |
1010
(?xi)
11-
\b(?>
11+
(?>
1212
(
13-
# Postgres jsonb functions.
14-
jsonb_to_tsvector|to_jsonb?|(?>array|row)_to_json
15-
| jsonb?_build_array|jsonb?(?:_build)?_object
16-
| jsonb?_(?>
17-
agg|array_(?>length|elements(?:_text)?)|each(?:_text)?
18-
| extract_path(?:_text)?|object_keys|populate_record(?:set)?
19-
| typeof|to_record(?:set)?|strip_nulls
20-
)
21-
| jsonb_(?>set|insert|pretty|path_exists|path_match|path_query(?>_array|_first)?)
22-
# Other Postgres functions.
23-
| greatest|least|random|to_ts(?>query|vector)|setweight
13+
# Scalar values.
14+
current_(?>catalog|role|schema) | localtime(?:stamp)?
2415
)
25-
| ((?<=\bdo\s)nothing | (?<=\bon\s)conflict)
16+
| (
2617
# Should always be keywords, but SQL.sublime-syntax doesn't think so yet.
2718
# Taken from https://www.postgresql.org/docs/current/sql-keywords-appendix.html
28-
| (
29-
all|any|array|analy[sz]e|a?symmetric|authorization|binary|both|by|cast|cross|column
30-
| concurrently|collat(?:e|ion)|create|distinct|(?<!\bas\s)do
19+
all|any|array|analy[sz]e|a?symmetric|authorization|binary|both|by
20+
| (?<=\bdo\s)nothing|(?<=\bon\s)conflict
21+
| cast|cross|column|concurrently|collat(?:e|ion)|create|distinct|(?<!\bas\s)do
3122
| except|excluded(?=\s*\.)|fetch|for(?:eign)?|freeze|full|group|intersect|into|inner|isnull
3223
| i[sn]|ilike|lateral|leading|left|natural|not(?:null)?|nullif|on(?:ly)?|offset|order|outer
3324
| over(?:laps)?|primary|recursive|returning|right|similar|some|table(?:sample)?|to|trailing
3425
| unnest|unique|user|variadic|verbose|window
3526
)
3627
| (nulls | (?<=\bnulls\s)last)
37-
# Some common functions.
38-
| (
39-
now|coalesce|current_(?>catalog|role|schema)?|localtime(?:stamp)?
40-
| (?>array|string)_agg|rand|replace|row_number
41-
)
4228
)\b
4329
# Various Postgres operators.
4430
| (::|\|?\|/|!!?|<<|>>|[%^@|&#~])
@@ -55,30 +41,38 @@ contexts:
5541
# Table and member identifier.
5642
| ((?!\d)\w+) (\s*\.\s*) (\s*(?!\d)\w+)
5743
# Accessor punctuation.
58-
| (\.)
44+
| (\.(?!\d))
5945
captures:
60-
1: support.function.psql
46+
1: support.function.scalar.sql
6147
2: keyword.other.sql
62-
3: keyword.other.sql
63-
4: constant.language.sql
64-
5: support.function.sql
65-
6: keyword.operator.psql
66-
7: storage.type.psql
67-
8: constant.character.escape.char.elixir
68-
9: keyword.operator.jsonb.psql
69-
10: keyword.operator.jsonb.psql
70-
11: constant.other.placeholder.elixir
71-
12: constant.other.parameter.sql
72-
13: constant.other.database-name.sql
73-
14: constant.other.table-name.sql
48+
3: constant.language.sql
49+
4: keyword.operator.psql
50+
5: storage.type.psql
51+
6: constant.character.escape.char.elixir
52+
7: keyword.operator.jsonb.psql
53+
8: keyword.operator.jsonb.psql
54+
9: constant.other.placeholder.elixir
55+
10: constant.other.parameter.sql
56+
11: constant.other.database-name.sql
57+
12: constant.other.table-name.sql
58+
13: punctuation.accessor.dot.sql
59+
14: variable.other.member.sql
7460
15: punctuation.accessor.dot.sql
75-
16: variable.other.member.sql
76-
17: punctuation.accessor.dot.sql
7761
7862
- include: comment
7963
- include: scope:source.sql
80-
- match: (?!\d)\w+
81-
scope: variable.other.sql
64+
65+
- match: |
66+
(?x)
67+
((?!\d)\w+)(?=\()
68+
| ((?!\d)\w+)
69+
| (\d+ (\.)? (?:\d* (?:[eE][-+]? \d+)?)? | (\.) \d+ (?:[eE][-+]? \d+)?)
70+
captures:
71+
1: variable.function.sql
72+
2: variable.other.sql
73+
3: constant.numeric.sql
74+
4: punctuation.separator.decimal.sql
75+
5: punctuation.separator.decimal.sql
8276
8377
comment:
8478
- match: /\*

0 commit comments

Comments
 (0)