crates/highlight/syntaxes/sql.json 4.9 KiB raw
1
{
2
  "displayName": "SQL",
3
  "fileTypes": [
4
    "sql"
5
  ],
6
  "name": "sql",
7
  "patterns": [
8
    {
9
      "include": "#comments"
10
    },
11
    {
12
      "include": "#strings"
13
    },
14
    {
15
      "include": "#quoted-identifiers"
16
    },
17
    {
18
      "include": "#numbers"
19
    },
20
    {
21
      "include": "#constants"
22
    },
23
    {
24
      "include": "#functions"
25
    },
26
    {
27
      "include": "#data-types"
28
    },
29
    {
30
      "include": "#keywords"
31
    },
32
    {
33
      "include": "#operators"
34
    },
35
    {
36
      "include": "#punctuation"
37
    }
38
  ],
39
  "repository": {
40
    "comments": {
41
      "patterns": [
42
        {
43
          "begin": "/\\*",
44
          "beginCaptures": {
45
            "0": {
46
              "name": "punctuation.definition.comment.begin.sql"
47
            }
48
          },
49
          "end": "\\*/",
50
          "endCaptures": {
51
            "0": {
52
              "name": "punctuation.definition.comment.end.sql"
53
            }
54
          },
55
          "name": "comment.block.sql"
56
        },
57
        {
58
          "match": "--.*$",
59
          "name": "comment.line.double-dash.sql"
60
        }
61
      ]
62
    },
63
    "constants": {
64
      "patterns": [
65
        {
66
          "match": "\\b(?i:(true|false|null|unknown))\\b",
67
          "name": "constant.language.sql"
68
        },
69
        {
70
          "match": "\\b(?i:(current_date|current_time|current_timestamp|localtime|localtimestamp|session_user|system_user|user))\\b",
71
          "name": "constant.language.sql"
72
        }
73
      ]
74
    },
75
    "data-types": {
76
      "patterns": [
77
        {
78
          "match": "\\b(?i:(bigint|binary|bit|blob|boolean|char|character|clob|date|decimal|double|float|int|integer|interval|json|jsonb|numeric|real|serial|smallint|text|time|timestamp|uuid|varbinary|varchar|varying|xml))\\b",
79
          "name": "storage.type.sql"
80
        }
81
      ]
82
    },
83
    "functions": {
84
      "patterns": [
85
        {
86
          "match": "\\b(?i:(avg|cast|coalesce|count|date_part|date_trunc|extract|lower|max|min|nullif|round|string_agg|sum|upper))\\b(?=\\s*\\()",
87
          "name": "support.function.sql"
88
        }
89
      ]
90
    },
91
    "keywords": {
92
      "patterns": [
93
        {
94
          "match": "\\b(?i:(add|alter|analyze|asc|begin|by|cascade|column|commit|constraint|create|database|default|delete|desc|distinct|drop|exists|explain|foreign|from|grant|group|having|index|insert|into|join|key|limit|not|offset|on|order|primary|references|returning|rollback|schema|select|set|table|temporary|truncate|union|unique|update|values|view|where|with))\\b",
95
          "name": "keyword.other.sql"
96
        },
97
        {
98
          "match": "\\b(?i:(all|and|any|as|between|case|else|end|except|for|full|if|in|inner|intersect|is|left|like|or|outer|over|right|then|when))\\b",
99
          "name": "keyword.control.sql"
100
        }
101
      ]
102
    },
103
    "numbers": {
104
      "patterns": [
105
        {
106
          "match": "\\b[+-]?(?:\\d+\\.\\d+|\\d+|\\.\\d+)(?:[eE][+-]?\\d+)?\\b",
107
          "name": "constant.numeric.sql"
108
        }
109
      ]
110
    },
111
    "operators": {
112
      "patterns": [
113
        {
114
          "match": "(<>|!=|<=|>=|:=|[-+*/%<>=])",
115
          "name": "keyword.operator.sql"
116
        }
117
      ]
118
    },
119
    "punctuation": {
120
      "patterns": [
121
        {
122
          "match": "[(),.;]",
123
          "name": "punctuation.separator.sql"
124
        }
125
      ]
126
    },
127
    "quoted-identifiers": {
128
      "patterns": [
129
        {
130
          "begin": "\"",
131
          "beginCaptures": {
132
            "0": {
133
              "name": "punctuation.definition.string.begin.sql"
134
            }
135
          },
136
          "end": "\"",
137
          "endCaptures": {
138
            "0": {
139
              "name": "punctuation.definition.string.end.sql"
140
            }
141
          },
142
          "name": "string.quoted.double.sql",
143
          "patterns": [
144
            {
145
              "match": "\"\"",
146
              "name": "constant.character.escape.sql"
147
            }
148
          ]
149
        },
150
        {
151
          "begin": "`",
152
          "beginCaptures": {
153
            "0": {
154
              "name": "punctuation.definition.string.begin.sql"
155
            }
156
          },
157
          "end": "`",
158
          "endCaptures": {
159
            "0": {
160
              "name": "punctuation.definition.string.end.sql"
161
            }
162
          },
163
          "name": "string.quoted.other.sql",
164
          "patterns": [
165
            {
166
              "match": "``",
167
              "name": "constant.character.escape.sql"
168
            }
169
          ]
170
        }
171
      ]
172
    },
173
    "strings": {
174
      "patterns": [
175
        {
176
          "begin": "'",
177
          "beginCaptures": {
178
            "0": {
179
              "name": "punctuation.definition.string.begin.sql"
180
            }
181
          },
182
          "end": "'",
183
          "endCaptures": {
184
            "0": {
185
              "name": "punctuation.definition.string.end.sql"
186
            }
187
          },
188
          "name": "string.quoted.single.sql",
189
          "patterns": [
190
            {
191
              "match": "''",
192
              "name": "constant.character.escape.sql"
193
            }
194
          ]
195
        }
196
      ]
197
    }
198
  },
199
  "scopeName": "source.sql"
200
}