diff --git a/Cargo.lock b/Cargo.lock index c19c18a91f44..5a1a988eba20 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4564,6 +4564,7 @@ dependencies = [ "tree-sitter-python", "tree-sitter-ruby", "tree-sitter-rust", + "tree-sitter-solidity", "tree-sitter-tags", "tree-sitter-typescript", ] @@ -5460,6 +5461,15 @@ dependencies = [ "tree-sitter", ] +[[package]] +name = "tree-sitter-solidity" +version = "0.0.3" +source = "git+https://github.com/JoranHonig/tree-sitter-solidity?rev=b239a95#b239a95f94cfcc6e7b3e961bc73a28d55e214f02" +dependencies = [ + "cc", + "tree-sitter", +] + [[package]] name = "tree-sitter-tags" version = "0.20.2" diff --git a/crates/tabby-common/assets/languages.toml b/crates/tabby-common/assets/languages.toml index 38975f950f86..baa22bccddcb 100644 --- a/crates/tabby-common/assets/languages.toml +++ b/crates/tabby-common/assets/languages.toml @@ -197,3 +197,18 @@ top_level_keywords = [ "trait", "use", ] + + +[[config]] +languages = ["solidity"] +line_comment = "//" +top_level_keywords = [ + "contract", + "interface", + "error", + "library", + "struct", + "enum", + "function", + "type", +] diff --git a/crates/tabby-scheduler/Cargo.toml b/crates/tabby-scheduler/Cargo.toml index d3f47b4b7fa6..ccb96d8c8550 100644 --- a/crates/tabby-scheduler/Cargo.toml +++ b/crates/tabby-scheduler/Cargo.toml @@ -22,6 +22,7 @@ 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" } tree-sitter-c-sharp = "0.20.0" +tree-sitter-solidity = { git = "https://github.com/JoranHonig/tree-sitter-solidity", rev = "b239a95" } ignore = "0.4.20" kdam = { version = "0.5.0" } requirements = "0.3.0" diff --git a/crates/tabby-scheduler/queries/solidity.scm b/crates/tabby-scheduler/queries/solidity.scm new file mode 100644 index 000000000000..aa1bbd35029d --- /dev/null +++ b/crates/tabby-scheduler/queries/solidity.scm @@ -0,0 +1,45 @@ +;; Copied from https://github.com/JoranHonig/tree-sitter-solidity/blob/master/queries/tags.scm +;; +;; Method and Function declarations +(contract_declaration (_ + (function_definition + name: (identifier) @name) @definition.method)) + +(source_file + (function_definition + name: (identifier) @name) @definition.function) + +;; Contract, struct, enum and interface declarations +(contract_declaration + name: (identifier) @name) @definition.class + +(interface_declaration + name: (identifier) @name) @definition.interface + +(library_declaration + name: (identifier) @name) @definition.interface + +(struct_declaration name: (identifier) @name) @definition.class +(enum_declaration name: (identifier) @name) @definition.class +(event_definition name: (identifier) @name) @definition.class + +;; Function calls +(call_expression (identifier) @name ) @reference.call + +(call_expression + (member_expression + property: (identifier) @name )) @reference.call + +;; Log emit +(emit_statement name: (identifier) @name) @reference.class + + +;; Inheritance + +(inheritance_specifier + ancestor: (user_defined_type (identifier) @name . )) @reference.class + + +;; Imports ( note that unknown is not standardised ) +(import_directive + import_name: (identifier) @name ) @reference.unknown diff --git a/crates/tabby-scheduler/src/dataset.rs b/crates/tabby-scheduler/src/dataset.rs index ab94c723f6e0..db746f566a3a 100644 --- a/crates/tabby-scheduler/src/dataset.rs +++ b/crates/tabby-scheduler/src/dataset.rs @@ -180,6 +180,7 @@ lazy_static! { ("python", vec!["py"]), ("ruby", vec!["rb"]), ("rust", vec!["rs"]), + ("solidity", vec!["sol"]), ("sql", vec!["sql"]), ("scala", vec!["scala"]), ("shellscript", vec!["sh", "bash", "command", "zsh"]), diff --git a/crates/tabby-scheduler/src/dataset/tags.rs b/crates/tabby-scheduler/src/dataset/tags.rs index 1f7a85594ad5..5429e09da7cd 100644 --- a/crates/tabby-scheduler/src/dataset/tags.rs +++ b/crates/tabby-scheduler/src/dataset/tags.rs @@ -153,6 +153,17 @@ lazy_static! { .unwrap(), ), ), + ( + "solidity", + TagsConfigurationSync( + TagsConfiguration::new( + tree_sitter_solidity::language(), + include_str!("../../queries/solidity.scm"), + "", + ) + .unwrap(), + ), + ), ]) }; } diff --git a/website/docs/programming-languages.md b/website/docs/programming-languages.md index 3b65ff162f06..ce0b084a1841 100644 --- a/website/docs/programming-languages.md +++ b/website/docs/programming-languages.md @@ -32,6 +32,7 @@ For an actual example of an issue or pull request adding the above support, plea * [C/C++](https://cplusplus.com/) * [PHP](https://www.php.net/) * [C#](https://learn.microsoft.com/en-us/dotnet/csharp/) +* [Solidity](https://soliditylang.org/): Since v0.10.0 ## Languages Missing Certain Support