Define a scala.scm of highlighting queries

pull/185/head
Wilfred Hughes 2022-03-26 23:26:21 +07:00
parent 5b1bc62ac6
commit 92b9680ecd
4 changed files with 85 additions and 2 deletions

@ -4,6 +4,8 @@
Difftastic no longer shows "1/1" when a file only has a single hunk.
Improved Scala syntax highlighting.
## 0.24 (release 26th March 2022)
### Diffing

@ -86,7 +86,7 @@ sample_files/ruby_before.rb sample_files/ruby_after.rb
4a9847a91e32ec6afdc2f0b01e28d2d6 -
sample_files/scala_before.scala sample_files/scala_after.scala
738f973ea0c3468e1db277116cf12516 -
0a7e7cf903bf816deda37f9a6871c94d -
sample_files/simple_before.js sample_files/simple_after.js
e4df6957f8e1d5f58cf9a72d18ee1193 -

@ -434,7 +434,11 @@ pub fn from_language(language: guess::Language) -> TreeSitterConfig {
language,
atom_nodes: (vec!["string", "template_string"]).into_iter().collect(),
delimiter_tokens: (vec![("{", "}"), ("(", ")"), ("[", "]")]),
highlight_query: ts::Query::new(language, "").unwrap(),
highlight_query: ts::Query::new(
language,
include_str!("../vendor/highlights/scala.scm"),
)
.unwrap(),
}
}
TypeScript => {

@ -0,0 +1,77 @@
;; TODO: upstream this.
;; Largely based on java.scm.
; Annotations
"@" @operator
; Types
(class_definition
name: (identifier) @type)
(trait_definition
name: (identifier) @type)
(object_definition
name: (identifier) @type)
(type_identifier) @type
;; Variables
((identifier) @constant
(#match? @constant "^_*[A-Z][A-Z\\d_]+$"))
(identifier) @variable
; Literals
[
(integer_literal)
(floating_point_literal)
] @number
[
(character_literal)
(string)
] @string
[
(boolean_literal)
(null_literal)
] @constant.builtin
(comment) @comment
; Keywords
[
"abstract"
"case"
"catch"
"class"
"def"
"do"
"else"
"extends"
"final"
"finally"
"for"
"if"
"implicit"
"import"
"lazy"
"new"
"object"
"override"
"package"
"private"
"protected"
"return"
"sealed"
"throw"
"trait"
"try"
"while"
"with"
] @keyword