on master help sign in
Add Scheme support

Skipped scm for now :/ it overlaps with tree-sitter-tsq

commitd25bae844c2a13f9d91c34a9016c3c6fd5cc26dc authorBlaž Hrastnik <blaz@mxxn.io> dateSun 22 May 2022, 00:00 (4 years ago) parent6bd8924
3 files changed+118
languages.toml+13 runtime/queries/scheme/highlights.scm+100 runtime/queries/scheme/injections.scm+5
languages.toml+13
@@ -1366,3 +1366,16 @@ roots = []
13661366[[grammar]]
13671367name = "sshclientconfig"
13681368source = { git = "https://github.com/metio/tree-sitter-ssh-client-config", rev = "769d7a01a2e5493b4bb5a51096c6bf4be130b024" }
1369+
1370+[[language]]
1371+name = "scheme"
1372+scope = "source.scheme"
1373+injection-regex = "scheme"
1374+file-types = ["ss", "rkt"] # "scm",
1375+roots = []
1376+comment-token = ";"
1377+indent = { tab-width = 2, unit = " " }
1378+
1379+[[grammar]]
1380+name = "scheme"
1381+source = { git = "https://github.com/6cdh/tree-sitter-scheme", rev = "27fb77db05f890c2823b4bd751c6420378df146b" }
runtime/queries/scheme/highlights.scmnew file+100
@@ -0,0 +1,100 @@
1+(number) @constant.numeric
2+(character) @constant.character
3+(boolean) @constant.builtin.boolean
4+
5+[(string)
6+ (character)] @string
7+
8+(escape_sequence) @constant.character.escape
9+
10+[(comment)
11+ (block_comment)
12+ (directive)] @comment
13+
14+[(boolean)
15+ (character)] @constant
16+
17+((symbol) @function.builtin
18+ (#match? @function.builtin "^(eqv\\?|eq\\?|equal\\?)")) ; TODO
19+
20+; keywords
21+
22+((symbol) @keyword.conditional
23+ (#match? @keyword.conditional "^(if|cond|case|when|unless)$"))
24+
25+((symbol) @keyword
26+ (#match? @keyword
27+ "^(define|lambda|begin|do|define-syntax|and|or|if|cond|case|when|unless|else|=>|let|let*|let-syntax|let-values|let*-values|letrec|letrec*|letrec-syntax|set!|syntax-rules|identifier-syntax|quote|unquote|quote-splicing|quasiquote|unquote-splicing|delay|assert|library|export|import|rename|only|except|prefix)$"))
28+
29+; special forms
30+
31+(list
32+ "["
33+ (symbol)+ @variable
34+ "]")
35+
36+(list
37+ .
38+ (symbol) @_f
39+ .
40+ (list
41+ (symbol) @variable)
42+ (#eq? @_f "lambda"))
43+
44+(list
45+ .
46+ (symbol) @_f
47+ .
48+ (list
49+ (list
50+ (symbol) @variable))
51+ (#match? @_f
52+ "^(let|let\\*|let-syntax|let-values|let\\*-values|letrec|letrec\\*|letrec-syntax)$"))
53+
54+; operators
55+
56+(list
57+ .
58+ (symbol) @operator
59+ (#match? @operator "^([+*/<>=-]|(<=)|(>=))$"))
60+
61+; quote
62+
63+(abbreviation
64+ "'" (symbol)) @constant
65+
66+(list
67+ .
68+ (symbol) @_f
69+ (#eq? @_f "quote")) @symbol
70+
71+; library
72+
73+(list
74+ .
75+ (symbol) @_lib
76+ .
77+ (symbol) @namespace
78+
79+ (#eq? @_lib "library"))
80+
81+; procedure
82+
83+(list
84+ .
85+ (symbol) @function)
86+
87+;; variables
88+
89+((symbol) @variable.builtin
90+ (#eq? @variable.builtin "..."))
91+
92+(symbol) @variable
93+((symbol) @variable.builtin
94+ (#eq? @variable.builtin "."))
95+
96+(symbol) @variable
97+
98+
99+["(" ")" "[" "]" "{" "}"] @punctuation.bracket
100+
runtime/queries/scheme/injections.scmnew file+5
@@ -0,0 +1,5 @@
1+((comment) @injection.content
2+ (#set! injection.language "comment"))
3+
4+((block_comment) @injection.content
5+ (#set! injection.language "comment"))