Add basic Ruby support

pull/70/head
Wilfred Hughes 2021-11-20 01:08:33 +07:00
parent 562634e6bc
commit a5ed3fbd48
9 changed files with 38 additions and 3 deletions

@ -2,9 +2,9 @@
### Parsing
Updated the C, CSS and JSON parsers to the latest upstream versions.
Added Ruby support.
No changes.
Updated the C, CSS and JSON parsers to the latest upstream versions.
## 0.12

@ -55,6 +55,7 @@ Difftastic supports the following languages:
* JSON
* OCaml
* Python
* Ruby
* Rust
* TypeScript (and TSX)

@ -28,6 +28,7 @@ impl TreeSitterParser {
.include(&dir)
.cpp(true)
.flag("--std=c++14")
.flag("-Wno-implicit-fallthrough")
.flag("-Wno-unused-parameter")
.flag("-Wno-ignored-qualifiers");
for file in cpp_files {
@ -126,6 +127,11 @@ fn main() {
src_dir: "vendor/tree-sitter-python-src".into(),
extra_files: vec!["scanner.cc".into()],
},
TreeSitterParser {
name: "tree-sitter-ruby".into(),
src_dir: "vendor/tree-sitter-ruby-src".into(),
extra_files: vec!["scanner.cc".into()],
},
TreeSitterParser {
name: "tree-sitter-rust".into(),
src_dir: "vendor/tree-sitter-rust-src".into(),

@ -1,7 +1,7 @@
# Introduction
Difftastic ([source on GitHub](https://github.com/wilfred/difftastic)) is a diff
tool that understands syntax. It currently supports 18 languages:
tool that understands syntax. It currently supports 19 languages:
* C
* C++
@ -17,6 +17,7 @@ tool that understands syntax. It currently supports 18 languages:
* JSON
* OCaml
* Python
* Ruby
* Rust
* TypeScript (and TSX)

@ -0,0 +1,3 @@
# Hello world
gem "jekyll", "~> #{Jekyll::VERSION}"
foo ""

@ -0,0 +1,2 @@
# Hello world
gem "jekyll", "~> #{Jekyll::VERSION}"

@ -44,6 +44,7 @@ extern "C" {
fn tree_sitter_ocaml() -> Language;
fn tree_sitter_ocaml_interface() -> Language;
fn tree_sitter_python() -> Language;
fn tree_sitter_ruby() -> Language;
fn tree_sitter_rust() -> Language;
fn tree_sitter_tsx() -> Language;
fn tree_sitter_typescript() -> Language;
@ -200,6 +201,25 @@ pub fn from_extension(extension: &OsStr) -> Option<TreeSitterConfig> {
delimiter_tokens: (vec![("(", ")"), ("[", "]"), ("{", "}")]),
highlight_queries: include_str!("../vendor/highlights/python.scm"),
}),
"rb" => Some(TreeSitterConfig {
name: "Ruby",
language: unsafe { tree_sitter_ruby() },
atom_nodes: (vec!["escape_sequence", "string_content"])
.into_iter()
.collect(),
delimiter_tokens: (vec![
("{", "}"),
("(", ")"),
("[", "]"),
("|", "|"),
// TODO: why doesn't this work on Jekyll commit 369c34510782ac8?
// ("\"", "\""),
("def", "end"),
("begin", "end"),
("class", "end"),
]),
highlight_queries: include_str!("../vendor/highlights/ruby.scm"),
}),
"rs" => Some(TreeSitterConfig {
name: "Rust",
language: unsafe { tree_sitter_rust() },

@ -0,0 +1 @@
../tree-sitter-ruby/queries/highlights.scm

@ -0,0 +1 @@
tree-sitter-ruby/src