on master help sign in
Add syntax docu, add VimL, CMake, INI, LESS syntax

closes #99 closes #106

commit54a331d162c8f2fa872f223102508753e3ba9939 authorsharkdp <davidpeter@web.de> dateFri 18 May 2018, 19:35 (8 years ago) parent5e3b17e
9 files changed+181
.gitmodules+12 assets/README.md+31 assets/syntaxes.bin assets/syntaxes/CMake+1 assets/syntaxes/INI+1 assets/syntaxes/INI.sublime-syntax+43 assets/syntaxes/LESS+1 assets/syntaxes/VimL+1 assets/syntaxes/VimL.sublime-syntax+91
.gitmodules+12
@@ -19,3 +19,15 @@
1919[submodule "assets/syntaxes/Docker"]
2020 path = assets/syntaxes/Docker
2121 url = https://github.com/asbjornenge/Docker.tmbundle
22+[submodule "assets/syntaxes/VimL"]
23+ path = assets/syntaxes/VimL
24+ url = https://github.com/SalGnt/Sublime-VimL
25+[submodule "assets/syntaxes/INI"]
26+ path = assets/syntaxes/INI
27+ url = https://github.com/clintberry/sublime-text-2-ini
28+[submodule "assets/syntaxes/CMake"]
29+ path = assets/syntaxes/CMake
30+ url = https://github.com/zyxar/Sublime-CMakeLists
31+[submodule "assets/syntaxes/LESS"]
32+ path = assets/syntaxes/LESS
33+ url = https://github.com/danro/LESS-sublime
assets/README.mdnew file+31
@@ -0,0 +1,31 @@
1+## Syntax Highlighting in bat
2+
3+`bat` uses the [syntect](https://github.com/trishume/syntect) library to highlight source
4+code. As a basis, syntect uses [Sublime Text](https://www.sublimetext.com/) syntax definitions
5+in the `.sublime-syntax` format.
6+
7+In order to add new syntaxes to `bat`, follow these steps:
8+
9+1. Find a Sublime Text syntax for the given language, preferably in a separate Git repository
10+ which can be included as a submodule (under `assets/syntaxes`).
11+
12+2. If the Sublime Text syntax is only available as a `.tmLanguage` file, open the file in
13+ Sublime Text and convert it to a `.sublime-syntax` file via *Tools* -> *Developer* ->
14+ *New Syntax from XXX.tmLanguage...*. Save the new file in the `assets/syntaxes` folder.
15+
16+3. Run the `create.sh` script. It calls `bat cache --init` to parse all available
17+ `.sublime-syntax` files and serialize them to a `syntaxes.bin` file (in this folder).
18+
19+4. Re-compile `bat`. At compilation time, the `syntaxes.bin` file will be stored inside the
20+ `bat` binary.
21+
22+### Troubleshooting
23+
24+Make sure that the local cache does not interfere with the internally stored syntaxes and
25+themes (`bat cache --clear`).
26+
27+### Manual modifications
28+
29+The following files have been manually modified after converting from a `.tmLanguage` file:
30+
31+* `VimL.sublime-syntax` => added `.vimrc` file type.
assets/syntaxes.bin

Binary file not shown.

assets/syntaxes/CMakenew file+1

Submodule changed.

assets/syntaxes/INInew file+1

Submodule changed.

assets/syntaxes/INI.sublime-syntaxnew file+43
@@ -0,0 +1,43 @@
1+%YAML 1.2
2+---
3+# http://www.sublimetext.com/docs/3/syntax.html
4+name: INI
5+file_extensions:
6+ - ini
7+ - INI
8+ - inf
9+ - INF
10+ - reg
11+ - REG
12+ - lng
13+ - cfg
14+ - CFG
15+ - url
16+ - URL
17+ - .editorconfig
18+scope: source.ini
19+contexts:
20+ main:
21+ - match: ^\s*(;|#).*$\n?
22+ scope: comment.line.semicolon.ini
23+ captures:
24+ 1: punctuation.definition.comment.ini
25+ - match: '^\s*(\[)(.*?)(\])'
26+ scope: meta.tag.section.ini
27+ captures:
28+ 1: punctuation.definition.section.ini
29+ 2: entity.section.ini
30+ 3: punctuation.definition.section.ini
31+ - match: '^(\s*(["'']?)(.+?)(\2)\s*(=))?\s*((["'']?)(.*?)(\7))\s*(;.*)?$\n?'
32+ scope: meta.declaration.ini
33+ captures:
34+ 1: meta.property.ini
35+ 2: punctuation.definition.quote.ini
36+ 3: keyword.name.ini
37+ 4: punctuation.definition.quote.ini
38+ 5: punctuation.definition.equals.ini
39+ 6: meta.value.ini
40+ 7: punctuation.definition.quote.ini
41+ 8: string.name.value.ini
42+ 9: punctuation.definition.quote.ini
43+ 10: comment.declarationline.semicolon.ini
assets/syntaxes/LESSnew file+1

Submodule changed.

assets/syntaxes/VimLnew file+1

Submodule changed.

assets/syntaxes/VimL.sublime-syntaxnew file+91
@@ -0,0 +1,91 @@
1+%YAML 1.2
2+---
3+# http://www.sublimetext.com/docs/3/syntax.html
4+name: VimL
5+file_extensions:
6+ - vim
7+ - .vimrc
8+scope: source.viml
9+contexts:
10+ main:
11+ - include: comment
12+ - include: string_quoted_double
13+ - include: string_quoted_single
14+ - include: string_regex
15+ - include: inline_comment
16+ - include: number_int
17+ - include: number_hex
18+ - include: keyword
19+ - include: support_function
20+ - include: support_variable
21+ - include: support_type
22+ - include: function_params
23+ - include: function_definition
24+ - include: function_call
25+ - include: function
26+ - include: variable
27+ - include: expr
28+ comment:
29+ - match: ^\s*".*$
30+ scope: comment.line.quotes.viml
31+ captures:
32+ 1: punctuation.definition.comment.vim
33+ expr:
34+ - match: (\|\||&&|==(\?|#)?|(!|>|<)=(#|\?)?|(=|!)~(#|\?)?|(>|<)(#|\?)is|isnot|\.|\*|\\|%)
35+ scope: storage.function.viml
36+ function:
37+ - match: \b(fu(n|nction)?|end(f|fu|fun|function)?)\b
38+ scope: storage.function.viml
39+ function_call:
40+ - match: '(([sgbwtl]|)?:?[0-9a-zA-Z_#]+)(?=\()'
41+ scope: support.function.any-method
42+ function_definition:
43+ - match: '^\s*(function)\s*!?\s+(?=(s:)?[0-9a-zA-Z_#]+\s*\()'
44+ captures:
45+ 1: storage.function.viml
46+ push:
47+ - meta_scope: meta.function.viml
48+ - match: (\()
49+ captures:
50+ 1: punctuation.definition.parameters.begin.viml
51+ pop: true
52+ - match: "(s:)?[0-9a-zA-Z_#]+"
53+ scope: entity.name.function.viml
54+ function_params:
55+ - match: '-\w+='
56+ scope: support.type.viml
57+ inline_comment:
58+ - match: '(?!\$)(")(?!\{).*$\n?'
59+ scope: comment.line.quotes.viml
60+ captures:
61+ 1: punctuation.definition.comment.vim
62+ keyword:
63+ - match: \b(if|while|for|try|return|throw|end(if|for|while|try)?|au(g|group)|else(if|)?|do|in|catch|finally|:)\b
64+ scope: keyword.control.viml
65+ number_hex:
66+ - match: "#[0-9a-f]{6}"
67+ scope: constant.numeric.hex
68+ number_int:
69+ - match: '-?\d+'
70+ scope: constant.numeric.integer
71+ string_quoted_double:
72+ - match: '"(\\\\|\\"|\n[^\S\n]*\\|[^\n"])*"'
73+ scope: string.quoted.double.viml
74+ string_quoted_single:
75+ - match: '''(''''|\n[^\S\n]*\\|[^\n''])*'''
76+ scope: string.quoted.single.viml
77+ string_regex:
78+ - match: '/(\\\\|\\/|\n[^\S\n]*\\|[^\n/])*/'
79+ scope: string.regexp.viml
80+ support_function:
81+ - match: \b(set(local|global)?|let|command|filetype|colorscheme|\w*map|\w*a(b|brev)?|syn|exe(c|cute)?|ec(ho|)?|au(tocmd|)?)\b
82+ scope: support.function.viml
83+ support_type:
84+ - match: <.*?>
85+ scope: support.type.viml
86+ support_variable:
87+ - match: '\b(am(enu|)?|(hl|inc)?search|[Bb]uf([Nn]ew[Ff]ile|[Rr]ead)?|[Ff]ile[Tt]ype)\b'
88+ scope: support.variable.viml
89+ variable:
90+ - match: '([sSgGbBwWlLaAvV]:|@|$|&(?!&))\w*'
91+ scope: variable.other.viml