Merge pull request #1858 from zed-industries/add-lisp

Added tree sitter support for scheme and racket
This commit is contained in:
Mikayla Maki 2022-12-05 11:40:52 -08:00 committed by GitHub
commit f23f294b86
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 144 additions and 1 deletions

20
Cargo.lock generated
View file

@ -6566,6 +6566,15 @@ dependencies = [
"tree-sitter",
]
[[package]]
name = "tree-sitter-racket"
version = "0.0.1"
source = "git+https://github.com/zed-industries/tree-sitter-racket?rev=eb010cf2c674c6fd9a6316a84e28ef90190fe51a#eb010cf2c674c6fd9a6316a84e28ef90190fe51a"
dependencies = [
"cc",
"tree-sitter",
]
[[package]]
name = "tree-sitter-ruby"
version = "0.20.0"
@ -6586,6 +6595,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"
@ -7805,8 +7823,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",

View file

@ -104,6 +104,8 @@ 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/zed-industries/tree-sitter-racket", rev = "eb010cf2c674c6fd9a6316a84e28ef90190fe51a"}
url = "2.2"
[dev-dependencies]

View file

@ -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,8 @@ 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),
] {
languages.add(language(name, grammar, lsp_adapter));
}

View file

@ -0,0 +1,3 @@
("(" @open ")" @close)
("[" @open "]" @close)
("{" @open "}" @close)

View file

@ -0,0 +1,9 @@
name = "Racket"
path_suffixes = ["rkt"]
line_comment = "; "
autoclose_before = "])"
brackets = [
{ start = "[", end = "]", close = true, newline = false },
{ start = "(", end = ")", close = true, newline = false },
{ start = "\"", end = "\"", close = true, newline = false },
]

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,3 @@
(_ "[" "]") @indent
(_ "{" "}") @indent
(_ "(" ")") @indent

View file

@ -0,0 +1,10 @@
(list
.
(symbol) @start-symbol @context
.
[
(symbol) @name
(list . (symbol) @name)
]
(#match? @start-symbol "^define")
) @item

View file

@ -11,4 +11,4 @@
(begin "begin" @open "end" @close)
(module "module" @open "end" @close)
(_ . "def" @open "end" @close)
(_ . "class" @open "end" @close)
(_ . "class" @open "end" @close)

View file

@ -0,0 +1,3 @@
("(" @open ")" @close)
("[" @open "]" @close)
("{" @open "}" @close)

View file

@ -0,0 +1,9 @@
name = "Scheme"
path_suffixes = ["scm", "ss"]
line_comment = "; "
autoclose_before = "])"
brackets = [
{ start = "[", end = "]", close = true, newline = false },
{ start = "(", end = ")", close = true, newline = false },
{ start = "\"", end = "\"", close = true, newline = false },
]

View file

@ -0,0 +1,28 @@
["(" ")" "[" "]" "{" "}"] @punctuation.bracket
(number) @number
(character) @constant.builtin
(boolean) @constant.builtin
(symbol) @variable
(string) @string
(escape_sequence) @escape
[(comment)
(block_comment)
(directive)] @comment
((symbol) @operator
(#match? @operator "^(\\+|-|\\*|/|=|>|<|>=|<=)$"))
(list
.
(symbol) @function)
(list
.
(symbol) @keyword
(#match? @keyword
"^(define-syntax|let\\*|lambda|λ|case|=>|quote-splicing|unquote-splicing|set!|let|letrec|letrec-syntax|let-values|let\\*-values|do|else|define|cond|syntax-rules|unquote|begin|quote|let-syntax|and|if|quasiquote|letrec|delay|or|when|unless|identifier-syntax|assert|library|export|import|rename|only|except|prefix)$"
))

View file

@ -0,0 +1,3 @@
(_ "[" "]") @indent
(_ "{" "}") @indent
(_ "(" ")") @indent

View file

@ -0,0 +1,10 @@
(list
.
(symbol) @start-symbol @context
.
[
(symbol) @name
(list . (symbol) @name)
]
(#match? @start-symbol "^define")
) @item