Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ anyhow = "1.0.89"
tree-sitter = "0.26"
tree-sitter-ruby = "0.23.1"
tree-sitter-embedded-template = "0.25.0"
tree-sitter-rbs = "0.2.3"
insta = { version = "1.46", features = ["yaml"] }
2 changes: 1 addition & 1 deletion languages/rbs/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
(type_variable) @constant

(namespace
(constant) @module)
(constant) @type)

(builtin_type) @type.builtin

Expand Down
4 changes: 1 addition & 3 deletions languages/rbs/indents.scm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
(parameters)
(tuple_type)
(record_type)
] @indent.begin
] @indent

(_
"["
Expand All @@ -18,5 +18,3 @@
(_
"("
")" @end) @indent

(comment) @indent.ignore
18 changes: 18 additions & 0 deletions tests/rbs.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
mod support;

#[test]
fn parses_and_highlights_rbs() {
let source = "module Billing\n class Invoice\n def total: (Integer quantity) -> Numeric\n end\nend\n";
let query = std::fs::read_to_string("languages/rbs/highlights.scm").unwrap();
let captures = support::run_query(source, &query, "rbs");

assert!(captures
.iter()
.any(|capture| capture.name == "type" && capture.text == "Billing"));
assert!(captures
.iter()
.any(|capture| capture.name == "function.method" && capture.text == "total"));
assert!(captures
.iter()
.any(|capture| capture.name == "variable.parameter" && capture.text == "quantity"));
}
1 change: 1 addition & 0 deletions tests/support/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ fn language_for_id(language_id: &str) -> tree_sitter::Language {
match language_id {
"ruby" => tree_sitter_ruby::LANGUAGE.into(),
"erb" => tree_sitter_embedded_template::LANGUAGE.into(),
"rbs" => tree_sitter_rbs::LANGUAGE.into(),
_ => panic!("Unsupported language id for query tests: {language_id}"),
}
}
Expand Down
Loading