├── .gitignore
├── Comments.tmPreferences
├── LICENSE
├── README.md
├── GenericConfig.sublime-syntax
└── syntax_test_geco.cfg
/.gitignore:
--------------------------------------------------------------------------------
1 | *.sublime-project
2 | *.sublime-workspace
3 | *.cache
4 |
--------------------------------------------------------------------------------
/Comments.tmPreferences:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | name
6 | Comments
7 | scope
8 | source.genconfig
9 | settings
10 |
11 | shellVariables
12 |
13 |
14 | name
15 | TM_COMMENT_START
16 | value
17 | #
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2013 Sergey Kozlov
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of
6 | this software and associated documentation files (the "Software"), to deal in
7 | the Software without restriction, including without limitation the rights to
8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 | the Software, and to permit persons to whom the Software is furnished to do so,
10 | subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Sublime-GenericConfig
2 | =====================
3 |
4 | Sublime-GenericConfig adds syntax highlighting of the configuration files
5 | to Sublime Text 2 and Sublime Text 3.
6 |
7 | It aims to provide generic highlighting for files which are
8 | not supported by other plugins (for example ini files, nginx config).
9 |
10 | This plugin may be used for a wide range of configuration files
11 | because highlighting is based on common syntax constructions.
12 |
13 | *NOTE*: `0.0.6` is last version for Sublime Text 2.
14 |
15 | Supported constructions
16 | -----------------------
17 |
18 | * One line comments (`#`, `//`, `--` and `;`)
19 | * Block comments (`/* ... */`)
20 | * Numbers, hex values, numbers with units (`12M`, `10kHz` etc)
21 | * Color (`#ccc`, `#12ccff` etc)
22 | * Common constants (`true`/`false`, `yes`/`no` etc)
23 | * Strings (single quotes and double quoted)
24 | * Sections (`[name]`, ``, `name { ... }`)
25 | * Key-value constructions (`key = value`, `key: value`, `key value ...`)
26 | * Variables (`$name`, `%name`, `%name%`, `${name}` and few others)
27 | * Uppercase names (`SOME_NAME`)
28 | * URL-like strings (`http://name.org`, `some://name:port/path`)
29 | * RegEx-like strings (`^...$`)
30 | * Common operators (`+`, `-` etc)
31 | * Mime-like strings (`image/gif`, `multipart/form-data` etc)
32 | * Function call (`name()`)
33 |
--------------------------------------------------------------------------------
/GenericConfig.sublime-syntax:
--------------------------------------------------------------------------------
1 | %YAML 1.2
2 | ---
3 | # TODO: rework to use new SublimeText regex engine.
4 | name: Generic Config
5 | file_extensions:
6 | - cfg
7 | - conf
8 | - config
9 | - ini
10 | - pro
11 | - mak
12 | - mk
13 | - Doxyfile
14 | - inputrc
15 | - .inputrc
16 | - dircolors
17 | - .dircolors
18 | - gitmodules
19 | - .gitmodules
20 | - gitignore
21 | - .gitignore
22 | - gitattributes
23 | - .gitattributes
24 | scope: source.genconfig
25 | contexts:
26 | main:
27 | # "Color (with alpha): #aacc4322, #bf34fa, #ccc"
28 | - match: '(?:(?:^\s*)|\s+)#([a-fA-F0-9]{8}|[a-fA-F0-9]{6}|[a-fA-F0-9]{3})\b'
29 | scope: constant.other.genconfig
30 |
31 | # One line comment
32 | - match: (?:(?:^\s*)|\s+)(?:(#.*)|(--\s+.*)|(\/\/.*))$
33 | captures:
34 | 1: comment.line.number-sign.genconfig
35 | 2: comment.line.double-dash.genconfig
36 | 3: comment.line.double-slash.genconfig
37 | scope: meta.comment.genconfig
38 |
39 | # ; one line comment
40 | - match: (?:(?:^\s*)|(?:^.+\s+))(;.*)$
41 | scope: meta.comment.genconfig
42 | captures:
43 | 1: comment.line.number-sign.genconfig
44 |
45 | # c-like block comments.
46 | # NOTE: This block must have a space after opening literal to not break
47 | # other constructions like '/path/to/*.conf'
48 | - match: /\*+\s
49 | scope: comment.block.genconfig
50 | push: block_comment
51 |
52 | # IP
53 | - match: \b(?:\d+\.){3}\d+(?:(?:\:|\/)\d+)?\b
54 | scope: meta.ip.genconfig constant.other.genconfig
55 |
56 | # Number or number with unit (like 10k, 12M, 92dpi etc) and also hex like values 0xdf
57 | - match: \b[0-9]+([a-zA-Z]+)?\b
58 | scope: constant.numeric.genconfig
59 |
60 | # "function call: name()"
61 | - match: \b(\w+)\b\(
62 | scope: meta.function.genconfig
63 | captures:
64 | 1: entity.name.function.genconfig
65 |
66 | # Constant
67 | - match: \b(?i:true|false)\b
68 | scope: constant.language.genconfig
69 |
70 | # Constant
71 | - match: \b(?
75 | - match: (?:^\s*(\w+)\s*(?={))|(?:^\s*(\w+)\s*$)|(^\s*\[.*\]\s*$)|(^\s*\<.*\>\s*$)
76 | scope: storage.type.genconfig
77 |
78 | - match: '"'
79 | push: double_string
80 |
81 | - match: "'"
82 | push: single_string
83 |
84 | - match: \\"
85 | push: quoted_double_string
86 |
87 | - match: \\'
88 | push: quoted_single_string
89 |
90 | # Keywords
91 | - match: (^\s*|\b)(?|\?|\/|\*|\\|\||\:|\.|\,)
119 | scope: keyword.operator.genconfig
120 |
121 | # Mime types (text/plain, application/x-javascript etc)
122 | - match: \b(?
195 |
196 |
197 | #^^^^^ storage.type.genconfig
198 |
199 | bla
200 | # ^^^^^^ -storage.type.genconfig
201 |
202 | [dsds]
203 | #^^^^^ storage.type.genconfig
204 |
205 | dsds {
206 | #^^^ storage.type.genconfig
207 | # ^ -storage.type.genconfig
208 |
209 | # -- Keyword -----------------------------------------------------------------
210 |
211 | function|define|ifdef|ifndef|endif|macro
212 | #^^^^^^^ keyword.other.genconfig
213 | # ^^^^^^ keyword.other.genconfig
214 | # ^^^^^ keyword.other.genconfig
215 | # ^^^^^^ keyword.other.genconfig
216 | # ^^^^^ keyword.other.genconfig
217 | # ^^^^ keyword.other.genconfig
218 |
219 | insertmacro|index|location|alias|include
220 | #^^^^^^^^^^ keyword.other.genconfig
221 | # ^^^^^ keyword.other.genconfig
222 | # ^^^^^^^^ keyword.other.genconfig
223 | # ^^^^^ keyword.other.genconfig
224 | # ^^^^^^ keyword.other.genconfig
225 |
226 | rewrite|if|then|else|start|stop|restart
227 | #^^^^^^ keyword.other.genconfig
228 | # ^^ keyword.other.genconfig
229 | # ^^^^ keyword.other.genconfig
230 | # ^^^^ keyword.other.genconfig
231 | # ^^^^^ keyword.other.genconfig
232 | # ^^^^ keyword.other.genconfig
233 | # ^^^^^^^ keyword.other.genconfig
234 |
235 | with|alert|internal
236 | #^^^ keyword.other.genconfig
237 | # ^^^^^ keyword.other.genconfig
238 | # ^^^^^^^^ keyword.other.genconfig
239 |
240 | # -- Var ---------------------------------------------------------------------
241 |
242 | %name, %name%, $name, $name$, ${name}
243 | #^^^^ storage.source.genconfig
244 | # ^^^^^^ storage.source.genconfig
245 | # ^^^^^ storage.source.genconfig
246 | # ^^^^^^ storage.source.genconfig
247 | # ^^^^^^^ storage.source.genconfig
248 |
249 | %{name}, %(name), $(name)
250 | #^^^^^^ storage.source.genconfig
251 | # ^^^^^^^ storage.source.genconfig
252 | # ^^^^^^^ storage.source.genconfig
253 |
254 | # -- URL ---------------------------------------------------------------------
255 |
256 | http://name.org, ssh://111.22.33.4:42
257 | #^^^^^^^^^^^^^^ meta.url.genconfig
258 | #^^^^^^^^^^^^^^ constant.other.genconfig
259 | # ^^^^^^^^^^^^^^^^^^^^ meta.url.genconfig
260 | # ^^ -meta.url.genconfig
261 |
262 | 111.22.33.4/42
263 | #^^^^^^^^^^^^^ constant.other.genconfig
264 |
265 | # -- Key-value ---------------------------------------------------------------
266 |
267 | key = value
268 | #^^ variable.parameter.genconfig
269 | # ^ keyword.operator.genconfig
270 | # ^^^^^ source.genconfig
271 |
272 | key=value
273 | #^^ variable.parameter.genconfig
274 | # ^ keyword.operator.genconfig
275 | # ^^^^^ source.genconfig
276 |
277 | key: value
278 | #^^ variable.parameter.genconfig
279 | # ^ keyword.operator.genconfig
280 | # ^^^^^ source.genconfig
281 |
282 | key value
283 | #^^ variable.parameter.genconfig
284 | # ^^^^^ source.genconfig
285 |
286 | key "if"
287 | #^^ variable.parameter.genconfig
288 | # ^^^^ string.quoted.double.genconfig
289 |
290 | key="if"
291 | #^^ variable.parameter.genconfig
292 | # ^ keyword.operator.genconfig
293 | # ^^^^ string.quoted.double.genconfig
294 |
295 | default-driver=alsa
296 | #^^^^^^^^^^^^^ variable.parameter.genconfig
297 | # ^ keyword.operator.genconfig
298 | # ^^^^ source.genconfig
299 |
300 | # -- RegExp ------------------------------------------------------------------
301 |
302 | ^dsds$ ^if yes 127.0.0.1 #ss$
303 | #^^^^^ string.regexp.genconfig
304 | # ^^^^^^^^^^^^^^^^^^^^^^ string.regexp.genconfig
305 |
306 | # -- Operator ----------------------------------------------------------------
307 |
308 | 1 + 23 = 342 > 33 >= dss < d23 <= f3;
309 | # ^ keyword.operator.genconfig
310 | # ^ keyword.operator.genconfig
311 | # ^ keyword.operator.genconfig
312 | # ^^ keyword.operator.genconfig
313 | # ^ keyword.operator.genconfig
314 | # ^^ keyword.operator.genconfig
315 | # ^ -comment.line.number-sign.genconfig
316 |
317 | 2 != dsd ? dsds : dsds* dsd / dsd
318 | # ^^ keyword.operator.genconfig
319 | # ^ keyword.operator.genconfig
320 | # ^ keyword.operator.genconfig
321 | # ^ keyword.operator.genconfig
322 | # ^ keyword.operator.genconfig
323 |
324 | df % |= 43^ds-+ \ sds / some.bla, xx
325 | # ^ keyword.operator.genconfig
326 | # ^^ keyword.operator.genconfig
327 | # ^ keyword.operator.genconfig
328 | # ^^ keyword.operator.genconfig
329 | # ^ keyword.operator.genconfig
330 | # ^ keyword.operator.genconfig
331 | # ^ keyword.operator.genconfig
332 | # ^ keyword.operator.genconfig
333 |
334 | # -- Mime type ---------------------------------------------------------------
335 |
336 | ba text/plain, application/x-javascript
337 | # ^^^^^^^^^^ support.type.genconfig
338 | # ^^^^^^^^^^^^^^^^^^^^^^^^ support.type.genconfig
339 |
340 | # NOTE: if line starts with mime like string then detected as key/value.
341 | image/gif
342 | #^^^^^^^^ -support.type.genconfig
343 |
344 | # -- Function ----------------------------------------------------------------
345 |
346 | foo()
347 | #^^ entity.name.function.genconfig
348 |
349 | a = myfunc(b, c + 1, "dsds")
350 | # ^^^^^^ entity.name.function.genconfig
351 |
352 | #
353 | # -- Combined constructions --------------------------------------------------
354 | #
355 |
356 | sd > /* d ds */
357 | #^ variable.parameter.genconfig
358 | # ^ keyword.operator.genconfig
359 | # ^^ comment.block.genconfig
360 | # ^^ comment.block.genconfig
361 | d. /*** dsds ****/
362 | # <- variable.parameter.genconfig
363 | #^ keyword.operator.genconfig
364 | # ^^^^ comment.block.genconfig
365 | # ^^^^ comment.block.genconfig
366 | * dsds *****
367 | # ^ keyword.operator.genconfig
368 | # ^^^^^ keyword.operator.genconfig
369 |
370 |
371 | include /etc/ld.so.conf.d/*.conf
372 | #^^^^^^ keyword.other.genconfig
373 | # ^ keyword.operator.genconfig
374 | # ^ keyword.operator.genconfig
375 | # ^ keyword.operator.genconfig
376 | # ^ keyword.operator.genconfig
377 | # ^ keyword.operator.genconfig
378 | # ^^^ keyword.operator.genconfig
379 |
380 | address 192.168.1.250
381 | #^^^^^^ variable.parameter.genconfig
382 | # ^^^^^^^^^^^^^ meta.ip.genconfig constant.other.genconfig
383 | netmask 255.255.255.0
384 | #^^^^^^ variable.parameter.genconfig
385 | # ^^^^^^^^^^^^^ meta.ip.genconfig
386 | network 192.168.1.0:233
387 | #^^^^^^ variable.parameter.genconfig
388 | # ^^^^^^^^^^^^^^^ meta.ip.genconfig
389 | network 192.168.1.0/324
390 | #^^^^^^ variable.parameter.genconfig
391 | # ^^^^^^^^^^^^^^^ meta.ip.genconfig
392 |
393 | linux:LIBS += -z \
394 | # ^ keyword.operator.genconfig
395 | # ^^^^ support.constant.genconfig
396 | # ^^ keyword.operator.genconfig
397 | # ^ keyword.operator.genconfig
398 | defs \
399 | -z \
400 | origin \
401 | -z \
402 | now \
403 | -Wl,-rpath=\'\$\$ORIGIN\'
404 | # ^ keyword.operator.genconfig
405 | # ^ keyword.operator.genconfig
406 | # ^ keyword.operator.genconfig
407 | # ^ keyword.operator.genconfig
408 | # ^^^^^^^^^^^^^^ string.quoted.qsignle.genconfig
409 |
410 | # add library directory
411 | LIBS += -L../shared/project-2.5.0/vsprojects/Release -llibproject
412 | #^^^ support.constant.genconfig
413 | # ^^ keyword.operator.genconfig
414 |
415 |
416 | default_driver=alsa + $(name)
417 | #^^^^^^^^^^^^^ variable.parameter.genconfig
418 | # ^ keyword.operator.genconfig
419 | # ^ keyword.operator.genconfig
420 | # ^^^^^^^ storage.source.genconfig
421 |
422 | a = 2 + foo(d, d, s, 12, "sds")
423 | # <- variable.parameter.genconfig
424 | # ^ keyword.operator.genconfig
425 | # ^ constant.numeric.genconfig
426 | # ^ keyword.operator.genconfig
427 | # ^^^ entity.name.function.genconfig
428 | # ^ keyword.operator.genconfig
429 | # ^ keyword.operator.genconfig
430 | # ^ keyword.operator.genconfig
431 | # ^^ constant.numeric.genconfig
432 | # ^ keyword.operator.genconfig
433 | # ^^^^^ string.quoted.double.genconfig
--------------------------------------------------------------------------------