summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomohiro Hashidate <kakyoin.hierophant@gmail.com>2023-12-01 01:22:29 +0900
committerGitHub <noreply@github.com>2023-12-01 01:22:29 +0900
commitb41bbcbb9a2c5543d3bfa4cf7e2b0948a5f61ce6 (patch)
tree12070e4326d991e022a69db22ee2c38561987388
parentfeat(nim): added some captures and fixed some bugs (#5664) (diff)
downloadnvim-treesitter-b41bbcbb9a2c5543d3bfa4cf7e2b0948a5f61ce6.tar
nvim-treesitter-b41bbcbb9a2c5543d3bfa4cf7e2b0948a5f61ce6.tar.gz
nvim-treesitter-b41bbcbb9a2c5543d3bfa4cf7e2b0948a5f61ce6.tar.bz2
nvim-treesitter-b41bbcbb9a2c5543d3bfa4cf7e2b0948a5f61ce6.tar.lz
nvim-treesitter-b41bbcbb9a2c5543d3bfa4cf7e2b0948a5f61ce6.tar.xz
nvim-treesitter-b41bbcbb9a2c5543d3bfa4cf7e2b0948a5f61ce6.tar.zst
nvim-treesitter-b41bbcbb9a2c5543d3bfa4cf7e2b0948a5f61ce6.zip
feat: add rbs parser support (#5745)
-rw-r--r--README.md1
-rw-r--r--lockfile.json3
-rw-r--r--lua/nvim-treesitter/parsers.lua8
-rw-r--r--queries/rbs/folds.scm5
-rw-r--r--queries/rbs/highlights.scm117
-rw-r--r--queries/rbs/indents.scm24
-rw-r--r--queries/rbs/injections.scm2
7 files changed, 160 insertions, 0 deletions
diff --git a/README.md b/README.md
index 8a5c41651..5a334ca4e 100644
--- a/README.md
+++ b/README.md
@@ -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)
diff --git a/lockfile.json b/lockfile.json
index ad0480700..b6632930d 100644
--- a/lockfile.json
+++ b/lockfile.json
@@ -518,6 +518,9 @@
"rasi": {
"revision": "371dac6bcce0df5566c1cfebde69d90ecbeefd2d"
},
+ "rbs": {
+ "revision": "192eda46774fd0281cdd41d372d5b4da86148780"
+ },
"re2c": {
"revision": "47aa19cf5f7aba2ed30e2b377f7172df76e819a6"
},
diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua
index 86bb7e358..640018cff 100644
--- a/lua/nvim-treesitter/parsers.lua
+++ b/lua/nvim-treesitter/parsers.lua
@@ -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",
diff --git a/queries/rbs/folds.scm b/queries/rbs/folds.scm
new file mode 100644
index 000000000..ff8e7c588
--- /dev/null
+++ b/queries/rbs/folds.scm
@@ -0,0 +1,5 @@
+[
+ (class_decl)
+ (module_decl)
+ (interface_decl)
+] @fold
diff --git a/queries/rbs/highlights.scm b/queries/rbs/highlights.scm
new file mode 100644
index 000000000..e985e8e0a
--- /dev/null
+++ b/queries/rbs/highlights.scm
@@ -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
diff --git a/queries/rbs/indents.scm b/queries/rbs/indents.scm
new file mode 100644
index 000000000..f6da5b10b
--- /dev/null
+++ b/queries/rbs/indents.scm
@@ -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
diff --git a/queries/rbs/injections.scm b/queries/rbs/injections.scm
new file mode 100644
index 000000000..321c90add
--- /dev/null
+++ b/queries/rbs/injections.scm
@@ -0,0 +1,2 @@
+((comment) @injection.content
+ (#set! injection.language "comment"))