Added experimental support for scheme, racket, and commonlisp
This commit is contained in:
1 parent
46b5e02961
commit
b8372d8b08
16 files changed
+613
-14
No files matched your search
Generated
+30
@@ -6461,6 +6461,15 @@ dependencies = [
|
||||
"tree-sitter",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tree-sitter-commonlisp"
|
||||
version = "0.3.0"
|
||||
source = "git+https://github.com/theHamsta/tree-sitter-commonlisp?rev=c7e814975ab0d0d04333d1f32391c41180c58919#c7e814975ab0d0d04333d1f32391c41180c58919"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"tree-sitter",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tree-sitter-cpp"
|
||||
version = "0.20.0"
|
||||
@@ -6566,6 +6575,15 @@ dependencies = [
|
||||
"tree-sitter",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tree-sitter-racket"
|
||||
version = "0.0.1"
|
||||
source = "git+https://github.com/6cdh/tree-sitter-racket?rev=69ca563af3bcf9d67220532e0814786f2dc34db1#69ca563af3bcf9d67220532e0814786f2dc34db1"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"tree-sitter",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tree-sitter-ruby"
|
||||
version = "0.20.0"
|
||||
@@ -6586,6 +6604,15 @@ dependencies = [
|
||||
"tree-sitter",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tree-sitter-scheme"
|
||||
version = "0.2.0"
|
||||
source = "git+https://github.com/6cdh/tree-sitter-scheme?rev=af0fd1fa452cb2562dc7b5c8a8c55551c39273b9#af0fd1fa452cb2562dc7b5c8a8c55551c39273b9"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"tree-sitter",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tree-sitter-toml"
|
||||
version = "0.5.1"
|
||||
@@ -7796,6 +7823,7 @@ dependencies = [
|
||||
"toml",
|
||||
"tree-sitter",
|
||||
"tree-sitter-c",
|
||||
"tree-sitter-commonlisp",
|
||||
"tree-sitter-cpp",
|
||||
"tree-sitter-css",
|
||||
"tree-sitter-elixir",
|
||||
@@ -7805,8 +7833,10 @@ dependencies = [
|
||||
"tree-sitter-json 0.20.0",
|
||||
"tree-sitter-markdown",
|
||||
"tree-sitter-python",
|
||||
"tree-sitter-racket",
|
||||
"tree-sitter-ruby",
|
||||
"tree-sitter-rust",
|
||||
"tree-sitter-scheme",
|
||||
"tree-sitter-toml",
|
||||
"tree-sitter-typescript",
|
||||
"unindent",
|
||||
|
||||
@@ -104,6 +104,9 @@ tree-sitter-toml = { git = "https://github.com/tree-sitter/tree-sitter-toml", re
|
||||
tree-sitter-typescript = "0.20.1"
|
||||
tree-sitter-ruby = "0.20.0"
|
||||
tree-sitter-html = "0.19.0"
|
||||
tree-sitter-scheme = { git = "https://github.com/6cdh/tree-sitter-scheme", rev = "af0fd1fa452cb2562dc7b5c8a8c55551c39273b9"}
|
||||
tree-sitter-racket = { git = "https://github.com/6cdh/tree-sitter-racket", rev = "69ca563af3bcf9d67220532e0814786f2dc34db1"}
|
||||
tree-sitter-commonlisp = { git = "https://github.com/theHamsta/tree-sitter-commonlisp", rev = "c7e814975ab0d0d04333d1f32391c41180c58919" }
|
||||
url = "2.2"
|
||||
|
||||
[dev-dependencies]
|
||||
|
||||
@@ -14,6 +14,7 @@ mod language_plugin;
|
||||
mod python;
|
||||
mod ruby;
|
||||
mod rust;
|
||||
|
||||
mod typescript;
|
||||
|
||||
// 1. Add tree-sitter-{language} parser to zed crate
|
||||
@@ -127,6 +128,9 @@ pub async fn init(languages: Arc<LanguageRegistry>, _executor: Arc<Background>)
|
||||
tree_sitter_embedded_template::language(),
|
||||
Some(CachedLspAdapter::new(ruby::RubyLanguageServer).await),
|
||||
),
|
||||
("scheme", tree_sitter_scheme::language(), None),
|
||||
// ("racket", tree_sitter_racket::language(), None),
|
||||
("commonlisp", tree_sitter_commonlisp::language(), None),
|
||||
] {
|
||||
languages.add(language(name, grammar, lsp_adapter));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
name = "Racket"
|
||||
path_suffixes = ["lisp", "lsp", "l", "cl"]
|
||||
line_comment = "; "
|
||||
autoclose_before = "])"
|
||||
brackets = [
|
||||
{ start = "[", end = "]", close = true, newline = true },
|
||||
{ start = "(", end = ")", close = true, newline = true },
|
||||
{ start = "'", end = "'", close = false, newline = false },
|
||||
]
|
||||
@@ -0,0 +1,3 @@
|
||||
;; Copied from nvim: https://github.com/nvim-treesitter/nvim-treesitter/blob/master/queries/commonlisp/folds.scm
|
||||
|
||||
(source (list_lit) @fold)
|
||||
@@ -0,0 +1,189 @@
|
||||
;; Copied from nvim: https://raw.githubusercontent.com/nvim-treesitter/nvim-treesitter/master/queries/commonlisp/highlights.scm
|
||||
|
||||
(sym_lit) @variable
|
||||
|
||||
;; A highlighting for functions/macros in th cl namespace is available in theHamsta/nvim-treesitter-commonlisp
|
||||
;(list_lit . (sym_lit) @function.builtin (#cl-standard-function? @function.builtin))
|
||||
;(list_lit . (sym_lit) @function.builtin (#cl-standard-macro? @function.macro))
|
||||
|
||||
(dis_expr) @comment
|
||||
|
||||
(defun_keyword) @function.macro
|
||||
(defun_header
|
||||
function_name: (_) @function)
|
||||
(defun_header
|
||||
lambda_list: (list_lit (sym_lit) @parameter))
|
||||
(defun_header
|
||||
keyword: (defun_keyword "defmethod")
|
||||
lambda_list: (list_lit (list_lit . (sym_lit) . (sym_lit) @symbol)))
|
||||
(defun_header
|
||||
lambda_list: (list_lit (list_lit . (sym_lit) @parameter . (_))))
|
||||
(defun_header
|
||||
specifier: (sym_lit) @symbol)
|
||||
|
||||
[":" "::" "."] @punctuation.special
|
||||
|
||||
[
|
||||
(accumulation_verb)
|
||||
(for_clause_word)
|
||||
"for"
|
||||
"and"
|
||||
"finally"
|
||||
"thereis"
|
||||
"always"
|
||||
"when"
|
||||
"if"
|
||||
"unless"
|
||||
"else"
|
||||
"do"
|
||||
"loop"
|
||||
"below"
|
||||
"in"
|
||||
"from"
|
||||
"across"
|
||||
"repeat"
|
||||
"being"
|
||||
"into"
|
||||
"with"
|
||||
"as"
|
||||
"while"
|
||||
"until"
|
||||
"return"
|
||||
"initially"
|
||||
] @function.macro
|
||||
"=" @operator
|
||||
|
||||
(include_reader_macro) @symbol
|
||||
["#C" "#c"] @number
|
||||
|
||||
[(kwd_lit) (self_referential_reader_macro)] @symbol
|
||||
|
||||
(package_lit
|
||||
package: (_) @namespace)
|
||||
"cl" @namespace
|
||||
|
||||
(str_lit) @string
|
||||
|
||||
(num_lit) @number
|
||||
|
||||
((sym_lit) @boolean (#match? @boolean "^(t|T)$"))
|
||||
|
||||
(nil_lit) @constant.builtin
|
||||
|
||||
(comment) @comment
|
||||
|
||||
;; dynamic variables
|
||||
((sym_lit) @variable.builtin
|
||||
(#match? @variable.builtin "^[*].+[*]$"))
|
||||
|
||||
;; quote
|
||||
"'" @string.escape
|
||||
(format_specifier) @string.escape
|
||||
(quoting_lit) @string.escape
|
||||
|
||||
;; syntax quote
|
||||
"`" @string.escape
|
||||
"," @string.escape
|
||||
",@" @string.escape
|
||||
(syn_quoting_lit) @string.escape
|
||||
(unquoting_lit) @none
|
||||
(unquote_splicing_lit) @none
|
||||
|
||||
|
||||
["(" ")"] @punctuation.bracket
|
||||
|
||||
(block_comment) @comment
|
||||
|
||||
|
||||
(with_clause
|
||||
type: (_) @type)
|
||||
(for_clause
|
||||
type: (_) @type)
|
||||
|
||||
;; defun-like things
|
||||
(list_lit
|
||||
.
|
||||
(sym_lit) @function.macro
|
||||
.
|
||||
(sym_lit) @function
|
||||
(#eq? @function.macro "deftest"))
|
||||
|
||||
;;; Macros and Special Operators
|
||||
(list_lit
|
||||
.
|
||||
(sym_lit) @function.macro
|
||||
;; For a complete and more efficient version install theHamsta/nvim-treesitter-commonlisp
|
||||
(#any-of? @function.macro
|
||||
"let"
|
||||
"function"
|
||||
"the"
|
||||
"unwind-protect"
|
||||
"labels"
|
||||
"flet"
|
||||
"tagbody"
|
||||
"go"
|
||||
"symbol-macrolet"
|
||||
"symbol-macrolet"
|
||||
"progn"
|
||||
"prog1"
|
||||
"error"
|
||||
"or"
|
||||
"and"
|
||||
"defvar"
|
||||
"defparameter"
|
||||
"in-package"
|
||||
"defpackage"
|
||||
"case"
|
||||
"ecase"
|
||||
"typecase"
|
||||
"etypecase"
|
||||
"defstruct"
|
||||
"defclass"
|
||||
"if"
|
||||
"when"
|
||||
"unless"
|
||||
"cond"
|
||||
"switch"
|
||||
"declaim"
|
||||
"optimize"))
|
||||
|
||||
;; constant
|
||||
((sym_lit) @constant
|
||||
(#match? @constant "^[+].+[+]$"))
|
||||
|
||||
(var_quoting_lit
|
||||
marker: "#'" @symbol
|
||||
value: (_) @symbol)
|
||||
|
||||
["#" "#p" "#P"] @symbol
|
||||
|
||||
(list_lit
|
||||
.
|
||||
(sym_lit) @function.builtin
|
||||
;; For a complete and more efficient version install theHamsta/nvim-treesitter-commonlisp
|
||||
(#any-of? @function.builtin
|
||||
"mapcar"
|
||||
"reduce"
|
||||
"remove-if-not"
|
||||
"cons"
|
||||
"car"
|
||||
"last"
|
||||
"nth"
|
||||
"equal"
|
||||
"cdr"
|
||||
"first"
|
||||
"rest"
|
||||
"format"))
|
||||
|
||||
(list_lit
|
||||
.
|
||||
(sym_lit) @operator
|
||||
(#match? @operator "^([+*-+=<>]|<=|>=|/=)$"))
|
||||
|
||||
|
||||
((sym_lit) @symbol
|
||||
(#match? @symbol "^[&]"))
|
||||
|
||||
[(array_dimension) "#0A" "#0a"] @number
|
||||
|
||||
(char_lit) @character
|
||||
@@ -35,6 +35,18 @@ pub(crate) struct GithubReleaseAsset {
|
||||
pub browser_download_url: String,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub(crate) struct CodebergReleaseAsset {
|
||||
pub name: String,
|
||||
pub assets: Vec<GithubReleaseAsset>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub(crate) struct CodebergRelease {
|
||||
pub name: String,
|
||||
pub browser_download_url: String,
|
||||
}
|
||||
|
||||
pub async fn npm_package_latest_version(name: &str) -> Result<String> {
|
||||
let output = smol::process::Command::new("npm")
|
||||
.args(["info", name, "--json"])
|
||||
@@ -103,3 +115,12 @@ pub(crate) async fn latest_github_release(
|
||||
serde_json::from_slice(body.as_slice()).context("error deserializing latest release")?;
|
||||
Ok(release)
|
||||
}
|
||||
|
||||
// pub(crate) async fn latest_codeberg_release(
|
||||
// repo_name_with_owner: &str,
|
||||
// http: Arc<dyn HttpClient>,
|
||||
// ) -> anyhow::Result<CodebergRelease> {
|
||||
// let mut response = http.get(uri, body, follow_redirects);
|
||||
|
||||
// bail!("unimplemented :(");
|
||||
// }
|
||||
@@ -0,0 +1,9 @@
|
||||
name = "Racket"
|
||||
path_suffixes = ["rkt"]
|
||||
line_comment = "; "
|
||||
autoclose_before = "])"
|
||||
brackets = [
|
||||
{ start = "[", end = "]", close = true, newline = true },
|
||||
{ start = "(", end = ")", close = true, newline = true },
|
||||
{ start = "'", end = "'", close = false, newline = false },
|
||||
]
|
||||
@@ -0,0 +1,3 @@
|
||||
; Copied from nvim: https://github.com/nvim-treesitter/nvim-treesitter/blob/master/queries/racket/folds.scm
|
||||
|
||||
(program (list) @fold)
|
||||
@@ -0,0 +1,140 @@
|
||||
;; Copied from nvim: https://raw.githubusercontent.com/nvim-treesitter/nvim-treesitter/master/queries/racket/highlights.scm
|
||||
|
||||
;; A highlight query can override the highlights queries before it.
|
||||
;; So the order is important.
|
||||
;; We should highlight general rules, then highlight special forms.
|
||||
|
||||
;;------------------------------------------------------------------;;
|
||||
;; Basic highlights ;;
|
||||
;;------------------------------------------------------------------;;
|
||||
|
||||
(ERROR) @error
|
||||
|
||||
;; basic ;;
|
||||
|
||||
(number) @number
|
||||
(character) @character
|
||||
(boolean) @boolean
|
||||
(keyword) @symbol
|
||||
|
||||
;; string ;;
|
||||
|
||||
[(string)
|
||||
(here_string)
|
||||
(byte_string)] @string
|
||||
|
||||
(escape_sequence) @string.escape
|
||||
|
||||
(regex) @string.regex
|
||||
|
||||
;; comment ;;
|
||||
|
||||
[(comment)
|
||||
(block_comment)
|
||||
(sexp_comment)] @comment
|
||||
|
||||
;; symbol ;;
|
||||
|
||||
(symbol) @variable
|
||||
|
||||
((symbol) @comment
|
||||
(#match? @comment "^#[cC][iIsS]$"))
|
||||
|
||||
;; extension ;;
|
||||
|
||||
(extension) @keyword
|
||||
(lang_name) @variable.builtin
|
||||
|
||||
;; quote ;;
|
||||
|
||||
(quote) @symbol
|
||||
|
||||
;; list ;;
|
||||
|
||||
["(" ")" "[" "]" "{" "}"] @punctuation.bracket
|
||||
|
||||
;; procedure ;;
|
||||
|
||||
(list
|
||||
.
|
||||
(symbol) @function)
|
||||
|
||||
;;------------------------------------------------------------------;;
|
||||
;; Builtin highlights ;;
|
||||
;;------------------------------------------------------------------;;
|
||||
|
||||
;; The following lists are generated by a racket script:
|
||||
;; https://gist.github.com/6cdh/65619e761753eb4166d15185a6236040
|
||||
;; Don't edit them directly.
|
||||
|
||||
;; keyword ;;
|
||||
|
||||
(list
|
||||
.
|
||||
(symbol) @keyword
|
||||
(#any-of? @keyword
|
||||
"#%app" "#%datum" "#%declare" "#%expression" "#%module-begin" "#%plain-app" "#%plain-lambda" "#%plain-module-begin" "#%printing-module-begin" "#%provide" "#%require" "#%stratified-body" "#%top" "#%top-interaction" "#%variable-reference" "->" "->*" "->*m" "->d" "->dm" "->i" "->m" "..." ":do-in" "==" "=>" "_" "absent" "abstract" "all-defined-out" "all-from-out" "and" "any" "augment" "augment*" "augment-final" "augment-final*" "augride" "augride*" "begin" "begin-for-syntax" "begin0" "case" "case->" "case->m" "case-lambda" "class" "class*" "class-field-accessor" "class-field-mutator" "class/c" "class/derived" "combine-in" "combine-out" "command-line" "compound-unit" "compound-unit/infer" "cond" "cons/dc" "contract" "contract-out" "contract-pos/neg-doubling" "contract-struct" "contracted" "current-contract-region" "define" "define-compound-unit" "define-compound-unit/infer" "define-contract-struct" "define-custom-hash-types" "define-custom-set-types" "define-for-syntax" "define-local-member-name" "define-logger" "define-match-expander" "define-member-name" "define-module-boundary-contract" "define-namespace-anchor" "define-opt/c" "define-sequence-syntax" "define-serializable-class" "define-serializable-class*" "define-signature" "define-signature-form" "define-splicing-for-clause-syntax" "define-struct" "define-struct/contract" "define-struct/derived" "define-syntax" "define-syntax-rule" "define-syntaxes" "define-unit" "define-unit-binding" "define-unit-from-context" "define-unit/contract" "define-unit/new-import-export" "define-unit/s" "define-values" "define-values-for-export" "define-values-for-syntax" "define-values/invoke-unit" "define-values/invoke-unit/infer" "define/augment" "define/augment-final" "define/augride" "define/contract" "define/final-prop" "define/match" "define/overment" "define/override" "define/override-final" "define/private" "define/public" "define/public-final" "define/pubment" "define/subexpression-pos-prop" "define/subexpression-pos-prop/name" "delay" "delay/idle" "delay/name" "delay/strict" "delay/sync" "delay/thread" "do" "else" "except" "except-in" "except-out" "export" "extends" "failure-cont" "field" "field-bound?" "file" "flat-murec-contract" "flat-rec-contract" "for" "for*" "for*/and" "for*/async" "for*/first" "for*/fold" "for*/fold/derived" "for*/foldr" "for*/foldr/derived" "for*/hash" "for*/hasheq" "for*/hasheqv" "for*/last" "for*/list" "for*/lists" "for*/mutable-set" "for*/mutable-seteq" "for*/mutable-seteqv" "for*/or" "for*/product" "for*/set" "for*/seteq" "for*/seteqv" "for*/stream" "for*/sum" "for*/vector" "for*/weak-set" "for*/weak-seteq" "for*/weak-seteqv" "for-label" "for-meta" "for-space" "for-syntax" "for-template" "for/and" "for/async" "for/first" "for/fold" "for/fold/derived" "for/foldr" "for/foldr/derived" "for/hash" "for/hasheq" "for/hasheqv" "for/last" "for/list" "for/lists" "for/mutable-set" "for/mutable-seteq" "for/mutable-seteqv" "for/or" "for/product" "for/set" "for/seteq" "for/seteqv" "for/stream" "for/sum" "for/vector" "for/weak-set" "for/weak-seteq" "for/weak-seteqv" "gen:custom-write" "gen:dict" "gen:equal+hash" "gen:set" "gen:stream" "generic" "get-field" "hash/dc" "if" "implies" "import" "include" "include-at/relative-to" "include-at/relative-to/reader" "include/reader" "inherit" "inherit-field" "inherit/inner" "inherit/super" "init" "init-depend" "init-field" "init-rest" "inner" "inspect" "instantiate" "interface" "interface*" "invariant-assertion" "invoke-unit" "invoke-unit/infer" "lambda" "lazy" "let" "let*" "let*-values" "let-syntax" "let-syntaxes" "let-values" "let/cc" "let/ec" "letrec" "letrec-syntax" "letrec-syntaxes" "letrec-syntaxes+values" "letrec-values" "lib" "link" "local" "local-require" "log-debug" "log-error" "log-fatal" "log-info" "log-warning" "match" "match*" "match*/derived" "match-define" "match-define-values" "match-lambda" "match-lambda*" "match-lambda**" "match-let" "match-let*" "match-let*-values" "match-let-values" "match-letrec" "match-letrec-values" "match/derived" "match/values" "member-name-key" "mixin" "module" "module*" "module+" "nand" "new" "nor" "object-contract" "object/c" "only" "only-in" "only-meta-in" "only-space-in" "open" "opt/c" "or" "overment" "overment*" "override" "override*" "override-final" "override-final*" "parameterize" "parameterize*" "parameterize-break" "parametric->/c" "place" "place*" "place/context" "planet" "prefix" "prefix-in" "prefix-out" "private" "private*" "prompt-tag/c" "prop:dict/contract" "protect-out" "provide" "provide-signature-elements" "provide/contract" "public" "public*" "public-final" "public-final*" "pubment" "pubment*" "quasiquote" "quasisyntax" "quasisyntax/loc" "quote" "quote-syntax" "quote-syntax/prune" "recontract-out" "recursive-contract" "relative-in" "rename" "rename-in" "rename-inner" "rename-out" "rename-super" "require" "send" "send*" "send+" "send-generic" "send/apply" "send/keyword-apply" "set!" "set!-values" "set-field!" "shared" "stream" "stream*" "stream-cons" Line truncated
|
||||
))
|
||||
|
||||
;; builtin procedures
|
||||
|
||||
((symbol) @function.builtin
|
||||
(#any-of? @function.builtin
|
||||
"*" "*list/c" "+" "-" "/" "<" "</c" "<=" "<=/c" "=" "=/c" ">" ">/c" ">=" ">=/c" "abort-current-continuation" "abs" "absolute-path?" "acos" "add-between" "add1" "alarm-evt" "and/c" "andmap" "angle" "any/c" "append" "append*" "append-map" "apply" "argmax" "argmin" "arithmetic-shift" "arity-at-least" "arity-at-least-value" "arity-at-least?" "arity-checking-wrapper" "arity-includes?" "arity=?" "arrow-contract-info" "arrow-contract-info-accepts-arglist" "arrow-contract-info-chaperone-procedure" "arrow-contract-info-check-first-order" "arrow-contract-info?" "asin" "assert-unreachable" "assf" "assoc" "assq" "assv" "atan" "bad-number-of-results" "banner" "base->-doms/c" "base->-rngs/c" "base->?" "between/c" "bitwise-and" "bitwise-bit-field" "bitwise-bit-set?" "bitwise-ior" "bitwise-not" "bitwise-xor" "blame-add-car-context" "blame-add-cdr-context" "blame-add-context" "blame-add-missing-party" "blame-add-nth-arg-context" "blame-add-range-context" "blame-add-unknown-context" "blame-context" "blame-contract" "blame-fmt->-string" "blame-missing-party?" "blame-negative" "blame-original?" "blame-positive" "blame-replace-negative" "blame-replaced-negative?" "blame-source" "blame-swap" "blame-swapped?" "blame-update" "blame-value" "blame?" "boolean=?" "boolean?" "bound-identifier=?" "box" "box-cas!" "box-immutable" "box-immutable/c" "box/c" "box?" "break-enabled" "break-parameterization?" "break-thread" "build-chaperone-contract-property" "build-compound-type-name" "build-contract-property" "build-flat-contract-property" "build-list" "build-path" "build-path/convention-type" "build-string" "build-vector" "byte-pregexp" "byte-pregexp?" "byte-ready?" "byte-regexp" "byte-regexp?" "byte?" "bytes" "bytes->immutable-bytes" "bytes->list" "bytes->path" "bytes->path-element" "bytes->string/latin-1" "bytes->string/locale" "bytes->string/utf-8" "bytes-append" "bytes-append*" "bytes-close-converter" "bytes-convert" "bytes-convert-end" "bytes-converter?" "bytes-copy" "bytes-copy!" "bytes-environment-variable-name?" "bytes-fill!" "bytes-join" "bytes-length" "bytes-no-nuls?" "bytes-open-converter" "bytes-ref" "bytes-set!" "bytes-utf-8-index" "bytes-utf-8-length" "bytes-utf-8-ref" "bytes<?" "bytes=?" "bytes>?" "bytes?" "caaaar" "caaadr" "caaar" "caadar" "caaddr" "caadr" "caar" "cadaar" "cadadr" "cadar" "caddar" "cadddr" "caddr" "cadr" "call-in-continuation" "call-in-nested-thread" "call-with-atomic-output-file" "call-with-break-parameterization" "call-with-composable-continuation" "call-with-continuation-barrier" "call-with-continuation-prompt" "call-with-current-continuation" "call-with-default-reading-parameterization" "call-with-escape-continuation" "call-with-exception-handler" "call-with-file-lock/timeout" "call-with-immediate-continuation-mark" "call-with-input-bytes" "call-with-input-file" "call-with-input-file*" "call-with-input-string" "call-with-output-bytes" "call-with-output-file" "call-with-output-file*" "call-with-output-string" "call-with-parameterization" "call-with-semaphore" "call-with-semaphore/enable-break" "call-with-values" "call/cc" "call/ec" "car" "cartesian-product" "cdaaar" "cdaadr" "cdaar" "cdadar" "cdaddr" "cdadr" "cdar" "cddaar" "cddadr" "cddar" "cdddar" "cddddr" "cdddr" "cddr" "cdr" "ceiling" "channel-get" "channel-put" "channel-put-evt" "channel-put-evt?" "channel-try-get" "channel/c" "channel?" "chaperone-box" "chaperone-channel" "chaperone-continuation-mark-key" "chaperone-contract-property?" "chaperone-contract?" "chaperone-evt" "chaperone-hash" "chaperone-hash-set" "chaperone-of?" "chaperone-procedure" "chaperone-procedure*" "chaperone-prompt-tag" "chaperone-struct" "chaperone-struct-type" "chaperone-vector" "chaperone-vector*" "chaperone?" "char->integer" "char-alphabetic?" "char-blank?" "char-ci<=?" "char-ci<?" "char-ci=?" "char-ci>=?" "char-ci>?" "char-downcase" "char-foldcase" "char-general-category" "char-graphic?" "char-in" "char-in/c" "char-iso-control?" "char-lower-case?" "char-numeric?" "char-punctuation?" "char-ready?" "char-symbolic?" "char-title-case?" "char-titlecase" "char-upcase" "char-upper-case?" "char-utf-8-length" "char-whitespace?" "char<=?" "char<?" "char=?" "char>=?" "char>?" "char?" "check-duplicate-identifier" "check-duplicates" "checked-procedure-check-and-extract" "choice-evt" "class->interface" "class-info" "class-seal" "class-unseal" "class?" "cleanse-path" "close-input-port" "close-output-port" "coerce-chaperone-contract" "coerce-chaperone-contracts" "coerce-contract" "coerce-contract/f" "coerce-contracts" "coerce-flat-contract" "coerce-flat-contracts" "collect-garbage" "collection-file-path" "collection-path" "combinations" "combine-output" "compile" "compile-allow-set!-undefined" "compile-context-preservation-enabled" "compile-enforce-module-constants" "compile-syntax" "compile-target-machine?" "compiled-expression-recompile" "compiled-expression?" "compiled-module-expression?" "complete-path?" "complex?" "compose" "compose1" "conjoin" "conjugate" "cons" "cons/c" "cons?"Line truncated
|
||||
))
|
||||
|
||||
;; operators ;;
|
||||
|
||||
((symbol) @operator
|
||||
(#any-of? @operator
|
||||
"+" "-" "*" "/" "=" "<=" ">=" "<" ">"))
|
||||
|
||||
;; builtin variables ;;
|
||||
|
||||
((symbol) @variable.builtin
|
||||
(#any-of? @variable.builtin
|
||||
"always-evt" "block-device-type-bits" "character-device-type-bits" "check-tail-contract" "contract-continuation-mark-key" "contract-random-generate-fail" "directory-type-bits" "empty" "empty-sequence" "empty-stream" "eof" "equal<%>" "error-message-adjuster-key" "externalizable<%>" "failure-result/c" "false" "false/c" "fifo-type-bits" "file-type-bits" "for-clause-syntax-protect" "group-execute-bit" "group-permission-bits" "group-read-bit" "group-write-bit" "impersonator-prop:application-mark" "impersonator-prop:blame" "impersonator-prop:contracted" "legacy-match-expander?" "match-...-nesting" "match-expander?" "mixin-contract" "never-evt" "null" "object%" "other-execute-bit" "other-permission-bits" "other-read-bit" "other-write-bit" "pi" "pi.f" "predicate/c" "printable<%>" "prop:arity-string" "prop:arrow-contract" "prop:authentic" "prop:blame" "prop:chaperone-contract" "prop:checked-procedure" "prop:contract" "prop:contracted" "prop:custom-print-quotable" "prop:custom-write" "prop:dict" "prop:equal+hash" "prop:evt" "prop:exn:missing-module" "prop:exn:srclocs" "prop:expansion-contexts" "prop:flat-contract" "prop:impersonator-of" "prop:input-port" "prop:legacy-match-expander" "prop:liberal-define-context" "prop:match-expander" "prop:object-name" "prop:orc-contract" "prop:output-port" "prop:place-location" "prop:procedure" "prop:recursive-contract" "prop:rename-transformer" "prop:sealed" "prop:sequence" "prop:set!-transformer" "prop:stream" "regular-file-type-bits" "set-group-id-bit" "set-user-id-bit" "socket-type-bits" "sticky-bit" "struct:arity-at-least" "struct:arrow-contract-info" "struct:date" "struct:date*" "struct:exn" "struct:exn:break" "struct:exn:break:hang-up" "struct:exn:break:terminate" "struct:exn:fail" "struct:exn:fail:contract" "struct:exn:fail:contract:arity" "struct:exn:fail:contract:blame" "struct:exn:fail:contract:continuation" "struct:exn:fail:contract:divide-by-zero" "struct:exn:fail:contract:non-fixnum-result" "struct:exn:fail:contract:variable" "struct:exn:fail:filesystem" "struct:exn:fail:filesystem:errno" "struct:exn:fail:filesystem:exists" "struct:exn:fail:filesystem:missing-module" "struct:exn:fail:filesystem:version" "struct:exn:fail:network" "struct:exn:fail:network:errno" "struct:exn:fail:object" "struct:exn:fail:out-of-memory" "struct:exn:fail:read" "struct:exn:fail:read:eof" "struct:exn:fail:read:non-char" "struct:exn:fail:syntax" "struct:exn:fail:syntax:missing-module" "struct:exn:fail:syntax:unbound" "struct:exn:fail:unsupported" "struct:exn:fail:user" "struct:srcloc" "symbolic-link-type-bits" "syntax-local-match-introduce" "syntax-pattern-variable?" "the-unsupplied-arg" "true" "unspecified-dom" "user-execute-bit" "user-permission-bits" "user-read-bit" "user-write-bit" "writable<%>"
|
||||
))
|
||||
|
||||
(dot) @variable.builtin
|
||||
|
||||
;;------------------------------------------------------------------;;
|
||||
;; Special cases ;;
|
||||
;;------------------------------------------------------------------;;
|
||||
|
||||
(list
|
||||
"["
|
||||
(symbol) @variable
|
||||
"]")
|
||||
|
||||
(list
|
||||
.
|
||||
(symbol) @_p
|
||||
.
|
||||
(list
|
||||
(symbol) @variable)
|
||||
(#any-of? @_p
|
||||
"lambda" "λ" "define-values" "define-syntaxes" "define-values-for-export"
|
||||
"define-values-for-syntax"
|
||||
))
|
||||
|
||||
;;------------------------------------------------------------------;;
|
||||
;; Solve conflicts ;;
|
||||
;;------------------------------------------------------------------;;
|
||||
|
||||
;; See `:h treesitter`, and search `priority`
|
||||
|
||||
(list
|
||||
.
|
||||
(symbol) @include
|
||||
(#eq? @include "require")
|
||||
(#set! "priority" 101))
|
||||
|
||||
(quote
|
||||
.
|
||||
(symbol)
|
||||
(#set! "priority" 105)) @symbol
|
||||
|
||||
((sexp_comment) @comment
|
||||
(#set! "priority" 110))
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
; Copied from nvim: https://github.com/nvim-treesitter/nvim-treesitter/blob/master/queries/racket/injections.scm
|
||||
|
||||
[(comment)
|
||||
(block_comment)] @comment
|
||||
@@ -1,14 +0,0 @@
|
||||
("[" @open "]" @close)
|
||||
("{" @open "}" @close)
|
||||
("\"" @open "\"" @close)
|
||||
("do" @open "end" @close)
|
||||
|
||||
(block_parameters "|" @open "|" @close)
|
||||
(interpolation "#{" @open "}" @close)
|
||||
|
||||
(if "if" @open "end" @close)
|
||||
(unless "unless" @open "end" @close)
|
||||
(begin "begin" @open "end" @close)
|
||||
(module "module" @open "end" @close)
|
||||
(_ . "def" @open "end" @close)
|
||||
(_ . "class" @open "end" @close)
|
||||
@@ -0,0 +1,9 @@
|
||||
name = "Scheme"
|
||||
path_suffixes = ["scm", "ss", "mjs"]
|
||||
line_comment = "; "
|
||||
autoclose_before = "])"
|
||||
brackets = [
|
||||
{ start = "[", end = "]", close = true, newline = true },
|
||||
{ start = "(", end = ")", close = true, newline = true },
|
||||
{ start = "'", end = "'", close = false, newline = false },
|
||||
]
|
||||
@@ -0,0 +1,3 @@
|
||||
; Copied from nvim: https://github.com/nvim-treesitter/nvim-treesitter/blob/master/queries/scheme/folds.scm
|
||||
|
||||
(program (list) @fold)
|
||||
@@ -0,0 +1,183 @@
|
||||
;; Copied from nvim: https://github.com/nvim-treesitter/nvim-treesitter/blob/master/queries/scheme/highlights.scm
|
||||
|
||||
;; A highlight query can override the highlights queries before it.
|
||||
;; So the order is important.
|
||||
;; We should highlight general rules, then highlight special forms.
|
||||
|
||||
(number) @number
|
||||
(character) @character
|
||||
(boolean) @boolean
|
||||
(string) @string
|
||||
[(comment)
|
||||
(block_comment)] @comment
|
||||
|
||||
;; highlight for datum comment
|
||||
;; copied from ../clojure/highlights.scm
|
||||
([(comment) (directive)] @comment
|
||||
(#set! "priority" 105))
|
||||
|
||||
(escape_sequence) @string.escape
|
||||
|
||||
["(" ")" "[" "]" "{" "}"] @punctuation.bracket
|
||||
|
||||
;; variables
|
||||
|
||||
(symbol) @variable
|
||||
((symbol) @variable.builtin
|
||||
(#any-of? @variable.builtin "..." "."))
|
||||
|
||||
;; procedure
|
||||
|
||||
(list
|
||||
.
|
||||
(symbol) @function)
|
||||
|
||||
;; special forms
|
||||
|
||||
(list
|
||||
"["
|
||||
(symbol)+ @variable
|
||||
"]")
|
||||
|
||||
(list
|
||||
.
|
||||
(symbol) @_f
|
||||
.
|
||||
(list
|
||||
(symbol) @variable)
|
||||
(#any-of? @_f "lambda" "λ"))
|
||||
|
||||
(list
|
||||
.
|
||||
(symbol) @_f
|
||||
.
|
||||
(list
|
||||
(list
|
||||
(symbol) @variable))
|
||||
(#any-of? @_f
|
||||
"let" "let*" "let-syntax" "let-values" "let*-values" "letrec" "letrec*" "letrec-syntax"))
|
||||
|
||||
;; operators
|
||||
|
||||
((symbol) @operator
|
||||
(#any-of? @operator
|
||||
"+" "-" "*" "/" "=" "<=" ">=" "<" ">"))
|
||||
|
||||
;; keyword
|
||||
|
||||
((symbol) @keyword
|
||||
(#any-of? @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"))
|
||||
|
||||
((symbol) @conditional
|
||||
(#any-of? @conditional "if" "cond" "case" "when" "unless"))
|
||||
|
||||
;; quote
|
||||
|
||||
(abbreviation
|
||||
"'"
|
||||
(symbol)) @symbol
|
||||
|
||||
(list
|
||||
.
|
||||
(symbol) @_f
|
||||
(#eq? @_f "quote")) @symbol
|
||||
|
||||
;; library
|
||||
|
||||
(list
|
||||
.
|
||||
(symbol) @_lib
|
||||
.
|
||||
(symbol) @namespace
|
||||
|
||||
(#eq? @_lib "library"))
|
||||
|
||||
;; builtin procedures
|
||||
;; procedures in R5RS and R6RS but not in R6RS-lib
|
||||
|
||||
((symbol) @function.builtin
|
||||
(#any-of? @function.builtin
|
||||
;; eq
|
||||
"eqv?" "eq?" "equal?"
|
||||
;; number
|
||||
"number?" "complex?" "real?" "rational?" "integer?"
|
||||
"exact?" "inexact?"
|
||||
"zero?" "positive?" "negative?" "odd?" "even?" "finite?" "infinite?" "nan?"
|
||||
"max" "min"
|
||||
"abs" "quotient" "remainder" "modulo"
|
||||
"div" "div0" "mod" "mod0" "div-and-mod" "div0-and-mod0"
|
||||
"gcd" "lcm" "numerator" "denominator"
|
||||
"floor" "ceiling" "truncate" "round"
|
||||
"rationalize"
|
||||
"exp" "log" "sin" "cos" "tan" "asin" "acos" "atan"
|
||||
"sqrt" "expt"
|
||||
"exact-integer-sqrt"
|
||||
"make-rectangular" "make-polar" "real-part" "imag-part" "magnitude" "angle"
|
||||
"real-valued" "rational-valued?" "integer-valued?"
|
||||
"exact" "inexact" "exact->inexact" "inexact->exact"
|
||||
"number->string" "string->number"
|
||||
;; boolean
|
||||
"boolean?" "not" "boolean=?"
|
||||
;; pair
|
||||
"pair?" "cons"
|
||||
"car" "cdr"
|
||||
"caar" "cadr" "cdar" "cddr"
|
||||
"caaar" "caadr" "cadar" "caddr" "cdaar" "cdadr" "cddar" "cdddr"
|
||||
"caaaar" "caaadr" "caadar" "caaddr" "cadaar" "cadadr" "caddar" "cadddr"
|
||||
"cdaaar" "cdaadr" "cdadar" "cdaddr" "cddaar" "cddadr" "cdddar" "cddddr"
|
||||
"set-car!" "set-cdr!"
|
||||
;; list
|
||||
"null?" "list?"
|
||||
"list" "length" "append" "reverse" "list-tail" "list-ref"
|
||||
"map" "for-each"
|
||||
"memq" "memv" "member" "assq" "assv" "assoc"
|
||||
;; symbol
|
||||
"symbol?" "symbol->string" "string->symbol" "symbol=?"
|
||||
;; char
|
||||
"char?" "char=?" "char<?" "char>?" "char<=?" "char>=?"
|
||||
"char-ci=?" "char-ci<?" "char-ci>?" "char-ci<=?" "char-ci>=?"
|
||||
"char-alphabetic?" "char-numeric?" "char-whitespace?" "char-upper-case?" "char-lower-case?"
|
||||
"char->integer" "integer->char"
|
||||
"char-upcase" "char-downcase"
|
||||
;; string
|
||||
"string?" "make-string" "string" "string-length" "string-ref" "string-set!"
|
||||
"string=?" "string-ci=?" "string<?" "string>?" "string<=?" "string>=?"
|
||||
"string-ci<?" "string-ci>?" "string-ci<=?" "string-ci>=?"
|
||||
"substring" "string-append" "string->list" "list->string"
|
||||
"string-for-each"
|
||||
"string-copy" "string-fill!"
|
||||
"string-upcase" "string-downcase"
|
||||
;; vector
|
||||
"vector?" "make-vector" "vector" "vector-length" "vector-ref" "vector-set!"
|
||||
"vector->list" "list->vector" "vector-fill!" "vector-map" "vector-for-each"
|
||||
;; bytevector
|
||||
"bytevector?" "native-endianness"
|
||||
"make-bytevector" "bytevector-length" "bytevector=?" "bytevector-fill!"
|
||||
"bytevector-copy!" "bytevector-copy"
|
||||
;; error
|
||||
"error" "assertion-violation"
|
||||
;; control
|
||||
"procedure?" "apply" "force"
|
||||
"call-with-current-continuation" "call/cc"
|
||||
"values" "call-with-values" "dynamic-wind"
|
||||
"eval" "scheme-report-environment" "null-environment" "interaction-environment"
|
||||
;; IO
|
||||
"call-with-input-file" "call-with-output-file" "input-port?" "output-port?"
|
||||
"current-input-port" "current-output-port" "with-input-from-file" "with-output-to-file"
|
||||
"open-input-file" "open-output-file" "close-input-port" "close-output-port"
|
||||
;; input
|
||||
"read" "read-char" "peek-char" "eof-object?" "char-ready?"
|
||||
;; output
|
||||
"write" "display" "newline" "write-char"
|
||||
;; system
|
||||
"load" "transcript-on" "transcript-off"))
|
||||
@@ -0,0 +1,3 @@
|
||||
; Copied from nvim: https://github.com/nvim-treesitter/nvim-treesitter/blob/master/queries/scheme/injections.scm
|
||||
|
||||
(comment) @comment
|
||||
Reference in new issue
Block a user