Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add Solidity language #1681

Merged
merged 1 commit into from
Mar 28, 2024
Merged
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
10 changes: 10 additions & 0 deletions Cargo.lock

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

15 changes: 15 additions & 0 deletions crates/tabby-common/assets/languages.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]
1 change: 1 addition & 0 deletions crates/tabby-scheduler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
45 changes: 45 additions & 0 deletions crates/tabby-scheduler/queries/solidity.scm
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions crates/tabby-scheduler/src/dataset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"]),
Expand Down
11 changes: 11 additions & 0 deletions crates/tabby-scheduler/src/dataset/tags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,17 @@ lazy_static! {
.unwrap(),
),
),
(
"solidity",
TagsConfigurationSync(
TagsConfiguration::new(
tree_sitter_solidity::language(),
include_str!("../../queries/solidity.scm"),
"",
)
.unwrap(),
),
),
])
};
}
1 change: 1 addition & 0 deletions website/docs/programming-languages.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading