Skip to content

feat (tabby-common): Add Scala Language Support with Tree-Sitter Parsing #4080

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
11 changes: 11 additions & 0 deletions Cargo.lock

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

39 changes: 38 additions & 1 deletion crates/tabby-common/assets/languages.toml
Original file line number Diff line number Diff line change
@@ -355,7 +355,44 @@ exts = ["sql"]

[[config]]
languages = ["scala"]
exts = ["scala"]
exts = ["scala", "sbt"]
line_comment = "//"
top_level_keywords = [
"abstract",
"case",
"class",
"def",
"do",
"else",
"enum",
"extends",
"final",
"for",
"given",
"if",
"implicit",
"import",
"lazy",
"match",
"new",
"object",
"override",
"package",
"private",
"protected",
"return",
"sealed",
"then",
"throw",
"trait",
"try",
"type",
"val",
"var",
"while",
"with",
"yield",
]

[[config]]
languages = ["shellscript"]
1 change: 1 addition & 0 deletions crates/tabby-index/Cargo.toml
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@ tantivy = { workspace = true }
tracing = { workspace = true }
tree-sitter-tags = "0.22.6"
lazy_static = { workspace = true }
tree-sitter-scala = "0.22.1"
tree-sitter-python = "0.21.0"
tree-sitter-java = "0.21.0"
tree-sitter-kotlin = "0.3.6"
68 changes: 68 additions & 0 deletions crates/tabby-index/queries/scala.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@

(class_definition
name: (identifier) @name) @definition.class

(enum_definition
name: (identifier) @name) @definition.enum

(object_definition
name: (identifier) @name) @definition.object

(object_definition
name: (identifier) @name) @definition.trait


(class_parameter
name: (identifier) @name) @definition.class_parameter

(self_type (identifier) @name) @definition.parameter

(type_definition
name: (type_identifier) @name) @definition.type


(val_definition
pattern: (identifier) @name) @definition.val

(var_definition
pattern: (identifier) @name) @definition.var

(val_declaration
name: (identifier) @name) @definition.val_decl

(var_declaration
name: (identifier) @name) @definition.var_decl



(call_expression
function: (identifier) @name) @reference.call

(call_expression
function: (operator_identifier) @name) @reference.call

(call_expression
function: (field_expression
field: (identifier) @name)) @reference.call

((call_expression
function: (identifier) @name)
(#match? @name "^[A-Z]")) @reference.constructor

(generic_function
function: (identifier) @name) @reference.call

(interpolated_string_expression
interpolator: (identifier) @name) @reference.call


(function_definition
name: (identifier) @name) @definition.function


(function_declaration
name: (identifier) @name) @definition.function

(function_definition
name: (identifier) @name) @definition.function

11 changes: 11 additions & 0 deletions crates/tabby-index/src/code/languages.rs
Original file line number Diff line number Diff line change
@@ -48,6 +48,17 @@ lazy_static! {
.unwrap(),
),
),
(
"scala",
TagsConfigurationSync(
TagsConfiguration::new(
tree_sitter_scala::language(),
include_str!("../../queries/scala.scm"),
"",
)
.unwrap(),
),
),
(
"kotlin",
TagsConfigurationSync(
2 changes: 1 addition & 1 deletion website/docs/references/programming-languages.md
Original file line number Diff line number Diff line change
@@ -39,6 +39,7 @@ For an actual example of an issue or pull request adding the above support, plea
* [Elixir](https://elixir-lang.org)
* [OCaml](https://ocaml.org/)
* [GDScript](https://gdscript.com/)
* [Scala](https://www.scala-lang.org/)

## Languages Missing Certain Support

@@ -48,4 +49,3 @@ For an actual example of an issue or pull request adding the above support, plea
| Haskell | 🚫 | 🚫 |
| Julia | 🚫 | 🚫 |
| Perl | 🚫 | 🚫 |
| Scala | 🚫 | 🚫 |