File tree Expand file tree Collapse file tree 4 files changed +82
-13
lines changed Expand file tree Collapse file tree 4 files changed +82
-13
lines changed Original file line number Diff line number Diff line change @@ -6,4 +6,4 @@ Elixir grammar for [tree-sitter](https://github.com/tree-sitter/tree-sitter).
6
6
7
7
## Development
8
8
9
- See [ the docs] ( ./docs.md ) for development notes .
9
+ See [ the docs] ( ./docs/index .md ) for more details .
Original file line number Diff line number Diff line change
1
+ # Syntax highlighting
2
+
3
+ For detailed introduction see the official guide on [ Syntax highlighting] ( https://tree-sitter.github.io/tree-sitter/syntax-highlighting ) .
4
+
5
+ Briefly speaking, Tree-sitter uses the rules in ` queries/highlights.scm ` to annotate nodes
6
+ with specific tokens, then it maps those tokens to formatting style according to user-defined
7
+ theme.
8
+
9
+ To test highlighting using the CLI, you need to create local configuration.
10
+
11
+ ``` shell
12
+ # Create the config file
13
+ npx tree-sitter init-config
14
+ ```
15
+
16
+ The above command should print out the config location, so that you can further configure it.
17
+ Open the file and modify ` "parser-directories" ` to include the parent directory of ` tree-sitter-elixir ` .
18
+ Also, you can optionally customize the theme, here's a tiny subset of the One Dark theme:
19
+
20
+ ``` json
21
+ {
22
+ "number" : {
23
+ "color" : " #61afef" ,
24
+ "bold" : true
25
+ },
26
+ "string" : " #98c379" ,
27
+ "string.escape" : " #56b6c2" ,
28
+ "string.special" : " #61afef" ,
29
+ "string.regexp" : " #e06c75" ,
30
+ "type" : " #e06c75" ,
31
+ "comment" : {
32
+ "color" : " #5c6370" ,
33
+ "italic" : true
34
+ },
35
+ "punctuation" : " #abb2bf" ,
36
+ "punctuation.special" : " #be5046" ,
37
+ "operator" : {
38
+ "color" : " #d19a66" ,
39
+ "bold" : true
40
+ },
41
+ "variable" : " #abb2bf" ,
42
+ "function" : " #61afef" ,
43
+ "constant" : " #61afef" ,
44
+ "constant.builtin" : {
45
+ "color" : " #e06c75" ,
46
+ "bold" : true
47
+ },
48
+ "keyword" : " #c678dd" ,
49
+ "attribute" : " #e06c75" ,
50
+ "embedded" : null
51
+ }
52
+ ```
53
+
54
+ With this setup you can test highlighting on files using the Tree-sitter CLI.
55
+
56
+ ``` shell
57
+ npx tree-sitter highlight tmp/test.ex
58
+
59
+ npx tree-sitter highlight test/highlight/** /* .ex
60
+ ```
Original file line number Diff line number Diff line change
1
+ # Development notes
2
+
3
+ This documentation covers rationale behind some of the design and implementation decisions,
4
+ as well as basic Tree-sitter tips that are relevant.
5
+
6
+ ## Pages
7
+
8
+ * [ Parser] ( ./parser.md )
9
+ * [ Highlighting] ( ./highlighting.md )
10
+
11
+ ## Acknowledgements
12
+
13
+ While this parser is written from scratch, there were previous efforts that made
14
+ for a helpful reference:
15
+
16
+ * [ tree-sitter-elixir] ( https://github.com/ananthakumaran/tree-sitter-elixir ) developed
17
+ by [ @ananthakumaran ] ( https://github.com/ananthakumaran )
18
+ * [ tree-sitter-elixir] ( https://github.com/wingyplus/tree-sitter-elixir ) developed
19
+ by [ @wingyplus ] ( https://github.com/wingyplus ) and [ @Tuxified ] ( https://github.com/Tuxified )
Original file line number Diff line number Diff line change 1
- # Development notes
2
-
3
- ## Acknowledgements
4
-
5
- While this parser is written from scratch, there were previous efforts that made
6
- for a helpful reference:
7
-
8
- * [ tree-sitter-elixir] ( https://github.com/ananthakumaran/tree-sitter-elixir ) developed
9
- by [ @ananthakumaran ] ( https://github.com/ananthakumaran )
10
- * [ tree-sitter-elixir] ( https://github.com/wingyplus/tree-sitter-elixir ) developed
11
- by [ @wingyplus ] ( https://github.com/wingyplus ) and [ @Tuxified ] ( https://github.com/Tuxified )
1
+ # Parser
12
2
13
3
## The AST
14
4
@@ -39,7 +29,7 @@ like, have a look at the tests in `test/corpus/`.
39
29
40
30
## Getting started with Tree-sitter
41
31
42
- For official notes see the official guide on [Creating parsers](https://tree-sitter.github.io/tree-sitter/creating-parsers).
32
+ For detailed introduction see the official guide on [Creating parsers](https://tree-sitter.github.io/tree-sitter/creating-parsers).
43
33
44
34
Essentially, we define relevant language rules in `grammar.js`, based on which
45
35
Tree-sitter generates parser code (under `src/`). In some cases, we want to write
You can’t perform that action at this time.
0 commit comments