mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-07 17:26:56 +00:00
Merge pull request #1858 from zed-industries/add-lisp
Added tree sitter support for scheme and racket
This commit is contained in:
commit
f23f294b86
14 changed files with 144 additions and 1 deletions
20
Cargo.lock
generated
20
Cargo.lock
generated
|
@ -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",
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
|
3
crates/zed/src/languages/racket/brackets.scm
Normal file
3
crates/zed/src/languages/racket/brackets.scm
Normal file
|
@ -0,0 +1,3 @@
|
|||
("(" @open ")" @close)
|
||||
("[" @open "]" @close)
|
||||
("{" @open "}" @close)
|
9
crates/zed/src/languages/racket/config.toml
Normal file
9
crates/zed/src/languages/racket/config.toml
Normal 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 },
|
||||
]
|
40
crates/zed/src/languages/racket/highlights.scm
Normal file
40
crates/zed/src/languages/racket/highlights.scm
Normal file
File diff suppressed because one or more lines are too long
3
crates/zed/src/languages/racket/indents.scm
Normal file
3
crates/zed/src/languages/racket/indents.scm
Normal file
|
@ -0,0 +1,3 @@
|
|||
(_ "[" "]") @indent
|
||||
(_ "{" "}") @indent
|
||||
(_ "(" ")") @indent
|
10
crates/zed/src/languages/racket/outline.scm
Normal file
10
crates/zed/src/languages/racket/outline.scm
Normal file
|
@ -0,0 +1,10 @@
|
|||
(list
|
||||
.
|
||||
(symbol) @start-symbol @context
|
||||
.
|
||||
[
|
||||
(symbol) @name
|
||||
(list . (symbol) @name)
|
||||
]
|
||||
(#match? @start-symbol "^define")
|
||||
) @item
|
|
@ -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)
|
3
crates/zed/src/languages/scheme/brackets.scm
Normal file
3
crates/zed/src/languages/scheme/brackets.scm
Normal file
|
@ -0,0 +1,3 @@
|
|||
("(" @open ")" @close)
|
||||
("[" @open "]" @close)
|
||||
("{" @open "}" @close)
|
9
crates/zed/src/languages/scheme/config.toml
Normal file
9
crates/zed/src/languages/scheme/config.toml
Normal 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 },
|
||||
]
|
28
crates/zed/src/languages/scheme/highlights.scm
Normal file
28
crates/zed/src/languages/scheme/highlights.scm
Normal 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)$"
|
||||
))
|
3
crates/zed/src/languages/scheme/indents.scm
Normal file
3
crates/zed/src/languages/scheme/indents.scm
Normal file
|
@ -0,0 +1,3 @@
|
|||
(_ "[" "]") @indent
|
||||
(_ "{" "}") @indent
|
||||
(_ "(" ")") @indent
|
10
crates/zed/src/languages/scheme/outline.scm
Normal file
10
crates/zed/src/languages/scheme/outline.scm
Normal file
|
@ -0,0 +1,10 @@
|
|||
(list
|
||||
.
|
||||
(symbol) @start-symbol @context
|
||||
.
|
||||
[
|
||||
(symbol) @name
|
||||
(list . (symbol) @name)
|
||||
]
|
||||
(#match? @start-symbol "^define")
|
||||
) @item
|
Loading…
Reference in a new issue