From 5c4f8de46ce6b38db5ac9cb407e31e29d24728cc Mon Sep 17 00:00:00 2001 From: Dheeraj R Reddy Date: Sat, 16 Dec 2023 00:34:28 -0800 Subject: [PATCH] feat: add stop words / repository context support for C/C++ (#744) --- Cargo.lock | 20 ++++++++++++ crates/tabby-common/assets/languages.toml | 37 ++++++++++++++++++++++ crates/tabby-scheduler/Cargo.toml | 4 ++- crates/tabby-scheduler/src/dataset.rs | 2 +- crates/tabby-scheduler/src/dataset/tags.rs | 22 +++++++++++++ website/docs/programming-languages.md | 2 +- 6 files changed, 84 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 41f39049c221..d35caf63721a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3769,6 +3769,8 @@ dependencies = [ "tokio", "tracing", "tracing-test", + "tree-sitter-c", + "tree-sitter-cpp", "tree-sitter-go", "tree-sitter-java", "tree-sitter-kotlin", @@ -4579,6 +4581,24 @@ dependencies = [ "regex", ] +[[package]] +name = "tree-sitter-c" +version = "0.20.6" +source = "git+https://github.com/tree-sitter/tree-sitter-c/?rev=212a80f#212a80f86452bb1316324fa0db730cf52f29e05a" +dependencies = [ + "cc", + "tree-sitter", +] + +[[package]] +name = "tree-sitter-cpp" +version = "0.20.3" +source = "git+https://github.com/tree-sitter/tree-sitter-cpp?rev=a714740#a71474021410973b29bfe99440d57bcd750246b1" +dependencies = [ + "cc", + "tree-sitter", +] + [[package]] name = "tree-sitter-go" version = "0.20.0" diff --git a/crates/tabby-common/assets/languages.toml b/crates/tabby-common/assets/languages.toml index f190cb01767c..82cbab3883bb 100644 --- a/crates/tabby-common/assets/languages.toml +++ b/crates/tabby-common/assets/languages.toml @@ -114,6 +114,43 @@ top_level_keywords = [ "self", ] +[[config]] +languages = ["c"] +line_comment = "//" +top_level_keywords = [ + "const", + "enum", + "extern", + "inline", + "register", + "static", + "struct", + "typedef", + "union", + "volatile", +] + +[[config]] +languages = ["cpp"] +line_comment = "//" +top_level_keywords = [ + "auto", + "class", + "const", + "concept", + "enum", + "extern", + "inline", + "namespace", + "register", + "static", + "struct", + "template", + "typedef", + "union", + "volatile", +] + [[config]] languages = ["csharp"] line_comment = "//" diff --git a/crates/tabby-scheduler/Cargo.toml b/crates/tabby-scheduler/Cargo.toml index a8bc16ded872..09f0f06a9d77 100644 --- a/crates/tabby-scheduler/Cargo.toml +++ b/crates/tabby-scheduler/Cargo.toml @@ -21,7 +21,9 @@ tree-sitter-kotlin = "0.3.1" tree-sitter-rust = "0.20.3" tree-sitter-typescript = "0.20.3" tree-sitter-go = "0.20.0" -tree-sitter-ruby= "0.20.0" +tree-sitter-ruby = "0.20.0" +tree-sitter-c = { git = "https://github.com/tree-sitter/tree-sitter-c/", rev = "212a80f" } +tree-sitter-cpp = { git = "https://github.com/tree-sitter/tree-sitter-cpp", rev = "a714740" } ignore = "0.4.20" kdam = { version = "0.5.0" } requirements = "0.3.0" diff --git a/crates/tabby-scheduler/src/dataset.rs b/crates/tabby-scheduler/src/dataset.rs index e2c61a6ab9c3..34698654b440 100644 --- a/crates/tabby-scheduler/src/dataset.rs +++ b/crates/tabby-scheduler/src/dataset.rs @@ -149,7 +149,7 @@ lazy_static! { ("csharp", vec!["cs"]), ( "cpp", - vec!["cpp", "hpp", "c++", "h++", "cc", "hh", "C", "H"], + vec!["cpp", "hpp", "c++", "h++", "cc", "hh", "C", "H", "tcc"], ), ("css", vec!["css"]), ("dockerfile", vec!["Dockerfile"]), diff --git a/crates/tabby-scheduler/src/dataset/tags.rs b/crates/tabby-scheduler/src/dataset/tags.rs index 305d8cb00c38..8299e7bf4378 100644 --- a/crates/tabby-scheduler/src/dataset/tags.rs +++ b/crates/tabby-scheduler/src/dataset/tags.rs @@ -117,6 +117,28 @@ lazy_static! { .unwrap(), ), ), + ( + "c", + TagsConfigurationSync( + TagsConfiguration::new( + tree_sitter_c::language(), + tree_sitter_c::TAGS_QUERY, + "", + ) + .unwrap(), + ), + ), + ( + "cpp", + TagsConfigurationSync( + TagsConfiguration::new( + tree_sitter_cpp::language(), + tree_sitter_cpp::TAGS_QUERY, + "", + ) + .unwrap(), + ), + ), ]) }; } diff --git a/website/docs/programming-languages.md b/website/docs/programming-languages.md index 4b3658acd9bf..408a3162c8de 100644 --- a/website/docs/programming-languages.md +++ b/website/docs/programming-languages.md @@ -29,12 +29,12 @@ For an actual example of an issue or pull request adding the above support, plea * [Ruby](https://www.ruby-lang.org/) * [Java](https://www.java.com/) * [Kotlin](https://www.kotlinlang.org/) +* [C/C++](https://cplusplus.com/), since v0.8.0 ## Languages Missing Certain Support | Language | Stop Words (time to contribute: <5 min) | Repository Context (time to contribute: <1 hr) | | :------: | :-------------------------------------: | :--------------------------------------------: | -| C/C++ | 🚫 | 🚫 | | C# | 🚫 | 🚫 | | CSS | 🚫 | 🚫 | | Haskell | 🚫 | 🚫 |