chore: Extract languages from zed
crate (#8270)
- Moves languages module from `zed` into a separate crate. That way we have less of a long pole at the end of compilation. - Removes moot dependencies on editor/picker. This is totally harmless and might help in the future if we decide to decouple picker from editor. Before: ``` Number of crates that depend on 'picker' but not on 'editor': 1 Total number of crates that depend on 'picker': 13 Total number of crates that depend on 'editor': 30 ``` After: ``` Number of crates that depend on 'picker' but not on 'editor': 5 Total number of crates that depend on 'picker': 12 Total number of crates that depend on 'editor': 26 ``` The more crates depend on just picker but not editor, the better in that case. Release Notes: - N/A
This commit is contained in:
parent
7cf0696c89
commit
0f584cb353
309 changed files with 221 additions and 154 deletions
14
crates/languages/src/ruby/brackets.scm
Normal file
14
crates/languages/src/ruby/brackets.scm
Normal file
|
@ -0,0 +1,14 @@
|
|||
("[" @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)
|
40
crates/languages/src/ruby/config.toml
Normal file
40
crates/languages/src/ruby/config.toml
Normal file
|
@ -0,0 +1,40 @@
|
|||
name = "Ruby"
|
||||
grammar = "ruby"
|
||||
path_suffixes = [
|
||||
"rb",
|
||||
"Gemfile",
|
||||
"rake",
|
||||
"Rakefile",
|
||||
"ru",
|
||||
"thor",
|
||||
"cap",
|
||||
"capfile",
|
||||
"Capfile",
|
||||
"jbuilder",
|
||||
"rabl",
|
||||
"rxml",
|
||||
"builder",
|
||||
"gemspec",
|
||||
"rdoc",
|
||||
"thor",
|
||||
"pryrc",
|
||||
"simplecov",
|
||||
]
|
||||
first_line_pattern = '^#!.*\bruby\b'
|
||||
line_comments = ["# "]
|
||||
autoclose_before = ";:.,=}])>"
|
||||
brackets = [
|
||||
{ start = "{", end = "}", close = true, newline = true },
|
||||
{ start = "[", end = "]", close = true, newline = true },
|
||||
{ start = "(", end = ")", close = true, newline = true },
|
||||
{ start = "\"", end = "\"", close = true, newline = false, not_in = [
|
||||
"comment",
|
||||
"string",
|
||||
] },
|
||||
{ start = "'", end = "'", close = true, newline = false, not_in = [
|
||||
"comment",
|
||||
"string",
|
||||
] },
|
||||
]
|
||||
collapsed_placeholder = "# ..."
|
||||
word_characters = ["_", "$", "=", "@", "!", ":", "?"]
|
22
crates/languages/src/ruby/embedding.scm
Normal file
22
crates/languages/src/ruby/embedding.scm
Normal file
|
@ -0,0 +1,22 @@
|
|||
(
|
||||
(comment)* @context
|
||||
.
|
||||
[
|
||||
(module
|
||||
"module" @name
|
||||
name: (_) @name)
|
||||
(method
|
||||
"def" @name
|
||||
name: (_) @name
|
||||
body: (body_statement) @collapse)
|
||||
(class
|
||||
"class" @name
|
||||
name: (_) @name)
|
||||
(singleton_method
|
||||
"def" @name
|
||||
object: (_) @name
|
||||
"." @name
|
||||
name: (_) @name
|
||||
body: (body_statement) @collapse)
|
||||
] @item
|
||||
)
|
182
crates/languages/src/ruby/highlights.scm
Normal file
182
crates/languages/src/ruby/highlights.scm
Normal file
|
@ -0,0 +1,182 @@
|
|||
; Keywords
|
||||
|
||||
[
|
||||
"alias"
|
||||
"and"
|
||||
"begin"
|
||||
"break"
|
||||
"case"
|
||||
"class"
|
||||
"def"
|
||||
"do"
|
||||
"else"
|
||||
"elsif"
|
||||
"end"
|
||||
"ensure"
|
||||
"for"
|
||||
"if"
|
||||
"in"
|
||||
"module"
|
||||
"next"
|
||||
"or"
|
||||
"rescue"
|
||||
"retry"
|
||||
"return"
|
||||
"then"
|
||||
"unless"
|
||||
"until"
|
||||
"when"
|
||||
"while"
|
||||
"yield"
|
||||
] @keyword
|
||||
|
||||
((identifier) @keyword
|
||||
(#match? @keyword "^(private|protected|public)$"))
|
||||
|
||||
; Function calls
|
||||
|
||||
((identifier) @function.method.builtin
|
||||
(#eq? @function.method.builtin "require"))
|
||||
|
||||
"defined?" @function.method.builtin
|
||||
|
||||
(call
|
||||
method: [(identifier) (constant)] @function.method)
|
||||
|
||||
; Function definitions
|
||||
|
||||
(alias (identifier) @function.method)
|
||||
(setter (identifier) @function.method)
|
||||
(method name: [(identifier) (constant)] @function.method)
|
||||
(singleton_method name: [(identifier) (constant)] @function.method)
|
||||
|
||||
; Identifiers
|
||||
|
||||
((identifier) @constant.builtin
|
||||
(#match? @constant.builtin "^__(FILE|LINE|ENCODING)__$"))
|
||||
|
||||
(file) @constant.builtin
|
||||
(line) @constant.builtin
|
||||
(encoding) @constant.builtin
|
||||
|
||||
(hash_splat_nil
|
||||
"**" @operator
|
||||
) @constant.builtin
|
||||
|
||||
((constant) @constant
|
||||
(#match? @constant "^[A-Z\\d_]+$"))
|
||||
|
||||
(global_variable) @constant
|
||||
|
||||
(constant) @type
|
||||
|
||||
(self) @variable.special
|
||||
(super) @variable.special
|
||||
|
||||
[
|
||||
(class_variable)
|
||||
(instance_variable)
|
||||
] @variable.member
|
||||
|
||||
|
||||
; Literals
|
||||
|
||||
[
|
||||
(string)
|
||||
(bare_string)
|
||||
(subshell)
|
||||
(heredoc_body)
|
||||
(heredoc_beginning)
|
||||
] @string
|
||||
|
||||
[
|
||||
(simple_symbol)
|
||||
(delimited_symbol)
|
||||
(hash_key_symbol)
|
||||
(bare_symbol)
|
||||
] @string.special.symbol
|
||||
|
||||
(regex) @string.regex
|
||||
(escape_sequence) @escape
|
||||
|
||||
[
|
||||
(integer)
|
||||
(float)
|
||||
] @number
|
||||
|
||||
[
|
||||
(nil)
|
||||
(true)
|
||||
(false)
|
||||
] @constant.builtin
|
||||
|
||||
(comment) @comment
|
||||
|
||||
; Operators
|
||||
|
||||
[
|
||||
"!"
|
||||
"~"
|
||||
"+"
|
||||
"-"
|
||||
"**"
|
||||
"*"
|
||||
"/"
|
||||
"%"
|
||||
"<<"
|
||||
">>"
|
||||
"&"
|
||||
"|"
|
||||
"^"
|
||||
">"
|
||||
"<"
|
||||
"<="
|
||||
">="
|
||||
"=="
|
||||
"!="
|
||||
"=~"
|
||||
"!~"
|
||||
"<=>"
|
||||
"||"
|
||||
"&&"
|
||||
".."
|
||||
"..."
|
||||
"="
|
||||
"**="
|
||||
"*="
|
||||
"/="
|
||||
"%="
|
||||
"+="
|
||||
"-="
|
||||
"<<="
|
||||
">>="
|
||||
"&&="
|
||||
"&="
|
||||
"||="
|
||||
"|="
|
||||
"^="
|
||||
"=>"
|
||||
"->"
|
||||
(operator)
|
||||
] @operator
|
||||
|
||||
[
|
||||
","
|
||||
";"
|
||||
"."
|
||||
] @punctuation.delimiter
|
||||
|
||||
[
|
||||
"("
|
||||
")"
|
||||
"["
|
||||
"]"
|
||||
"{"
|
||||
"}"
|
||||
"%w("
|
||||
"%i("
|
||||
] @punctuation.bracket
|
||||
|
||||
(interpolation
|
||||
"#{" @punctuation.special
|
||||
"}" @punctuation.special) @embedded
|
17
crates/languages/src/ruby/indents.scm
Normal file
17
crates/languages/src/ruby/indents.scm
Normal file
|
@ -0,0 +1,17 @@
|
|||
(method "end" @end) @indent
|
||||
(class "end" @end) @indent
|
||||
(module "end" @end) @indent
|
||||
(begin "end" @end) @indent
|
||||
(do_block "end" @end) @indent
|
||||
|
||||
(then) @indent
|
||||
(call) @indent
|
||||
|
||||
(ensure) @outdent
|
||||
(rescue) @outdent
|
||||
(else) @outdent
|
||||
|
||||
|
||||
(_ "[" "]" @end) @indent
|
||||
(_ "{" "}" @end) @indent
|
||||
(_ "(" ")" @end) @indent
|
20
crates/languages/src/ruby/outline.scm
Normal file
20
crates/languages/src/ruby/outline.scm
Normal file
|
@ -0,0 +1,20 @@
|
|||
(class
|
||||
"class" @context
|
||||
name: (_) @name) @item
|
||||
|
||||
((identifier) @context
|
||||
(#match? @context "^(private|protected|public)$")) @item
|
||||
|
||||
(method
|
||||
"def" @context
|
||||
name: (_) @name) @item
|
||||
|
||||
(singleton_method
|
||||
"def" @context
|
||||
object: (_) @context
|
||||
"." @context
|
||||
name: (_) @name) @item
|
||||
|
||||
(module
|
||||
"module" @context
|
||||
name: (_) @name) @item
|
2
crates/languages/src/ruby/overrides.scm
Normal file
2
crates/languages/src/ruby/overrides.scm
Normal file
|
@ -0,0 +1,2 @@
|
|||
(comment) @comment
|
||||
(string) @string
|
Loading…
Add table
Add a link
Reference in a new issue