feat: add rbs parser support (#5745)

This commit is contained in:
Tomohiro Hashidate 2023-12-01 01:22:29 +09:00 committed by GitHub
parent 36f81e698e
commit b41bbcbb9a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 160 additions and 0 deletions

View file

@ -346,6 +346,7 @@ We are looking for maintainers to add more parsers and to write query files for
- [x] [r](https://github.com/r-lib/tree-sitter-r) (maintained by @echasnovski)
- [ ] [racket](https://github.com/6cdh/tree-sitter-racket)
- [x] [rasi](https://github.com/Fymyte/tree-sitter-rasi) (maintained by @Fymyte)
- [x] [rbs](https://github.com/joker1007/tree-sitter-rbs) (maintained by @joker1007)
- [x] [re2c](https://github.com/amaanq/tree-sitter-re2c) (maintained by @amaanq)
- [x] [regex](https://github.com/tree-sitter/tree-sitter-regex) (maintained by @theHamsta)
- [x] [rego](https://github.com/FallenAngel97/tree-sitter-rego) (maintained by @FallenAngel97)

View file

@ -518,6 +518,9 @@
"rasi": {
"revision": "371dac6bcce0df5566c1cfebde69d90ecbeefd2d"
},
"rbs": {
"revision": "192eda46774fd0281cdd41d372d5b4da86148780"
},
"re2c": {
"revision": "47aa19cf5f7aba2ed30e2b377f7172df76e819a6"
},

View file

@ -1536,6 +1536,14 @@ list.rasi = {
maintainers = { "@Fymyte" },
}
list.rbs = {
install_info = {
url = "https://github.com/joker1007/tree-sitter-rbs",
files = { "src/parser.c" },
},
maintainers = { "@joker1007" },
}
list.re2c = {
install_info = {
url = "https://github.com/amaanq/tree-sitter-re2c",

5
queries/rbs/folds.scm Normal file
View file

@ -0,0 +1,5 @@
[
(class_decl)
(module_decl)
(interface_decl)
] @fold

117
queries/rbs/highlights.scm Normal file
View file

@ -0,0 +1,117 @@
; Use directive
(use_clause
[
(type_name)
(simple_type_name)
] @type)
; Buitin constants and Keywords
[
"true"
"false"
] @boolean
"nil" @constant.builtin
[
"use"
"as"
"class"
"module"
"interface"
"type"
"def"
"attr_reader"
"attr_writer"
"attr_accessor"
"end"
"alias"
] @keyword
"def" @keyword.function
; Members of declaration
[
"include"
"extend"
"prepend"
] @function.method
(visibility) @type.qualifier
(comment) @comment @spell
(method_member
(method_name
[
(identifier)
(constant)
(operator)
(setter)
] @method))
[(ivar_name) (cvar_name)] @property
(alias_member (method_name) @function)
(class_name (constant) @type)
(module_name (constant) @type)
(interface_name (interface) @type)
(alias_name (identifier) @type)
(type_variable) @constant
(namespace (constant) @namespace)
(builtin_type) @type.builtin
(const_name (constant) @constant)
(global_name) @property
; Standard Arguments
(parameter (var_name) @parameter)
; Keyword Arguments
(keyword) @parameter
; Self
(self) @variable.builtin
; Literal
(type (symbol_literal) @symbol)
(type (string_literal (escape_sequence) @string.escape))
(type (string_literal) @string)
(type (integer_literal) @number)
; Operators
[
"="
"->"
"<"
"**"
"*"
"&"
"|"
"^"
] @operator
; Punctuation
[
"("
")"
"["
"]"
"{"
"}"
] @punctuation.bracket
[
","
"."
] @punctuation.delimiter

24
queries/rbs/indents.scm Normal file
View file

@ -0,0 +1,24 @@
[
(class_decl)
(module_decl)
(interface_decl)
(parameters)
(tuple_type)
(record_type)
] @indent.begin
[
"end"
")"
"]"
"}"
] @indent.end
[
"end"
")"
"}"
"]"
] @indent.branch
(comment) @indent.auto

View file

@ -0,0 +1,2 @@
((comment) @injection.content
(#set! injection.language "comment"))