diff options
author | Blaž Hrastnik | 2022-05-21 15:00:05 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2022-05-21 15:01:07 +0000 |
commit | d25bae844c2a13f9d91c34a9016c3c6fd5cc26dc (patch) | |
tree | 1d17ab96d5a12576371f19b5e6c8183429c59d4b | |
parent | 6bd8924436636c252ec2bfcd02986771665f0c02 (diff) |
Add Scheme support
Skipped scm for now :/ it overlaps with tree-sitter-tsq
-rw-r--r-- | languages.toml | 13 | ||||
-rw-r--r-- | runtime/queries/scheme/highlights.scm | 100 | ||||
-rw-r--r-- | runtime/queries/scheme/injections.scm | 5 |
3 files changed, 118 insertions, 0 deletions
diff --git a/languages.toml b/languages.toml index 5deed357..d3c4ef43 100644 --- a/languages.toml +++ b/languages.toml @@ -1366,3 +1366,16 @@ roots = [] [[grammar]] name = "sshclientconfig" source = { git = "https://github.com/metio/tree-sitter-ssh-client-config", rev = "769d7a01a2e5493b4bb5a51096c6bf4be130b024" } + +[[language]] +name = "scheme" +scope = "source.scheme" +injection-regex = "scheme" +file-types = ["ss", "rkt"] # "scm", +roots = [] +comment-token = ";" +indent = { tab-width = 2, unit = " " } + +[[grammar]] +name = "scheme" +source = { git = "https://github.com/6cdh/tree-sitter-scheme", rev = "27fb77db05f890c2823b4bd751c6420378df146b" } diff --git a/runtime/queries/scheme/highlights.scm b/runtime/queries/scheme/highlights.scm new file mode 100644 index 00000000..3b7a4275 --- /dev/null +++ b/runtime/queries/scheme/highlights.scm @@ -0,0 +1,100 @@ +(number) @constant.numeric +(character) @constant.character +(boolean) @constant.builtin.boolean + +[(string) + (character)] @string + +(escape_sequence) @constant.character.escape + +[(comment) + (block_comment) + (directive)] @comment + +[(boolean) + (character)] @constant + +((symbol) @function.builtin + (#match? @function.builtin "^(eqv\\?|eq\\?|equal\\?)")) ; TODO + +; keywords + +((symbol) @keyword.conditional + (#match? @keyword.conditional "^(if|cond|case|when|unless)$")) + +((symbol) @keyword + (#match? @keyword + "^(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)$")) + +; special forms + +(list + "[" + (symbol)+ @variable + "]") + +(list + . + (symbol) @_f + . + (list + (symbol) @variable) + (#eq? @_f "lambda")) + +(list + . + (symbol) @_f + . + (list + (list + (symbol) @variable)) + (#match? @_f + "^(let|let\\*|let-syntax|let-values|let\\*-values|letrec|letrec\\*|letrec-syntax)$")) + +; operators + +(list + . + (symbol) @operator + (#match? @operator "^([+*/<>=-]|(<=)|(>=))$")) + +; quote + +(abbreviation + "'" (symbol)) @constant + +(list + . + (symbol) @_f + (#eq? @_f "quote")) @symbol + +; library + +(list + . + (symbol) @_lib + . + (symbol) @namespace + + (#eq? @_lib "library")) + +; procedure + +(list + . + (symbol) @function) + +;; variables + +((symbol) @variable.builtin + (#eq? @variable.builtin "...")) + +(symbol) @variable +((symbol) @variable.builtin + (#eq? @variable.builtin ".")) + +(symbol) @variable + + +["(" ")" "[" "]" "{" "}"] @punctuation.bracket + diff --git a/runtime/queries/scheme/injections.scm b/runtime/queries/scheme/injections.scm new file mode 100644 index 00000000..aebb54d9 --- /dev/null +++ b/runtime/queries/scheme/injections.scm @@ -0,0 +1,5 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +((block_comment) @injection.content + (#set! injection.language "comment")) |