diff --git a/Cargo.lock b/Cargo.lock index 44855c511fd0..baac196feb6a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3221,6 +3221,7 @@ dependencies = [ "tracing-test", "tree-sitter-go", "tree-sitter-python", + "tree-sitter-ruby", "tree-sitter-rust", "tree-sitter-tags", "tree-sitter-typescript", @@ -3960,6 +3961,16 @@ dependencies = [ "tree-sitter", ] +[[package]] +name = "tree-sitter-ruby" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ac30cbb1560363ae76e1ccde543d6d99087421e228cc47afcec004b86bb711a" +dependencies = [ + "cc", + "tree-sitter", +] + [[package]] name = "tree-sitter-rust" version = "0.20.3" diff --git a/crates/tabby-common/assets/languages.toml b/crates/tabby-common/assets/languages.toml index b13fcd609d26..017eb1734969 100644 --- a/crates/tabby-common/assets/languages.toml +++ b/crates/tabby-common/assets/languages.toml @@ -50,4 +50,52 @@ top_level_keywords = [ "import", "var", "const", -] \ No newline at end of file +] + +[[config]] +languages = ["ruby"] +line_comment = "#" +# from https://docs.ruby-lang.org/en/3.2/keywords_rdoc.html +top_level_keywords = [ + "__ENCODING__", + "__LINE__", + "__FILE__", + "BEGIN", + "END", + "alias", + "and", + "begin", + "break", + "case", + "class", + "def", + "defined?", + "do", + "else", + "elsif", + "end", + "ensure", + "false", + "for", + "if", + "in", + "module", + "next", + "nil", + "not", + "or", + "redo", + "rescue", + "retry", + "return", + "self", + "super", + "then", + "true", + "undef", + "unless", + "until", + "when", + "while", + "yield", +] diff --git a/crates/tabby-scheduler/Cargo.toml b/crates/tabby-scheduler/Cargo.toml index 531f6fdfbc4c..2f50b3cf8bf0 100644 --- a/crates/tabby-scheduler/Cargo.toml +++ b/crates/tabby-scheduler/Cargo.toml @@ -22,6 +22,7 @@ tree-sitter-python = "0.20.2" tree-sitter-rust = "0.20.3" tree-sitter-typescript = "0.20.3" tree-sitter-go = "0.20.0" +tree-sitter-ruby= "0.20.0" [dev-dependencies] temp_testdir = "0.2" diff --git a/crates/tabby-scheduler/queries/ruby.scm b/crates/tabby-scheduler/queries/ruby.scm new file mode 100644 index 000000000000..84f1ed2d41b1 --- /dev/null +++ b/crates/tabby-scheduler/queries/ruby.scm @@ -0,0 +1,66 @@ +; https://github.com/tree-sitter/tree-sitter-ruby/blob/master/queries/tags.scm + +; Method definitions + +( + (comment)* @doc + . + [ + (method + name: (_) @name) @definition.method + (singleton_method + name: (_) @name) @definition.method + ] + (#strip! @doc "^#\\s*") + (#select-adjacent! @doc @definition.method) + ) + +(alias + name: (_) @name) @definition.method + +(setter + (identifier) @ignore) + +; Class definitions + +( + (comment)* @doc + . + [ + (class + name: [ + (constant) @name + (scope_resolution + name: (_) @name) + ]) @definition.class + (singleton_class + value: [ + (constant) @name + (scope_resolution + name: (_) @name) + ]) @definition.class + ] + (#strip! @doc "^#\\s*") + (#select-adjacent! @doc @definition.class) +) + +; Module definitions + +( + (module + name: [ + (constant) @name + (scope_resolution + name: (_) @name) + ]) @definition.module +) + +; Calls + +(call method: (identifier) @name) @reference.call + +( + [(identifier) (constant)] @name @reference.call + (#is-not? local) + (#not-match? @name "^(lambda|load|require|require_relative|__FILE__|__LINE__)$") +) diff --git a/crates/tabby-scheduler/src/dataset.rs b/crates/tabby-scheduler/src/dataset.rs index c6eb965dd491..389fbc6edb5c 100644 --- a/crates/tabby-scheduler/src/dataset.rs +++ b/crates/tabby-scheduler/src/dataset.rs @@ -270,6 +270,18 @@ lazy_static! { .unwrap(), ), ), + ( + "ruby", + TagsConfigurationSync( + TagsConfiguration::new( + tree_sitter_go::language(), + include_str!("../queries/ruby.scm"), + "", + ) + .unwrap(), + ), + ), + ]) }; } diff --git a/website/docs/programming-languages.md b/website/docs/programming-languages.md index 6bdec398a25a..8ca2996d1461 100644 --- a/website/docs/programming-languages.md +++ b/website/docs/programming-languages.md @@ -26,6 +26,7 @@ For an actual example of an issue or pull request adding the above support, plea * [JavaScript](https://developer.mozilla.org/en-US/docs/Web/JavaScript) * [TypeScript](https://www.typescriptlang.org/) * [Golang](https://go.dev/): Since v0.4.0 +* [Ruby](https://www.ruby-lang.org/) ## Languages Missing Certain Support @@ -40,5 +41,4 @@ For an actual example of an issue or pull request adding the above support, plea | Lua | 🚫 | 🚫 | | PHP | 🚫 | 🚫 | | Perl | 🚫 | 🚫 | -| Ruby | 🚫 | 🚫 | | Scala | 🚫 | 🚫 |