Skip to content

Commit d96244a

Browse files
committed
v0.11.1 (resolve #25)
1 parent 1d512bb commit d96244a

File tree

14 files changed

+548
-830
lines changed

14 files changed

+548
-830
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
### 0.11.1
2+
- (Bugfix) - Helix themes now properly inherit from parent names when not defined (that is, if `ui.x.y` isn't defined but `ui.x` is, `ui.x.y` copies `ui.x`.) (Thanks @guilhermeprokisch for catching this one.)
3+
- (Bugfix) - example terminal highlighter now works properly.
4+
- (Bugfix) - updated Rust and Ada highlighting queries to behave properly.
5+
16
### 0.11.0
27
- (Improvement, **breaking**) - the `Theme` API has been rebuilt to work with [Helix editor themes](https://docs.helix-editor.com/themes.html#modifiers) instead of the previous bespoke implementation.
38
- The `theme` module has been hoisted out of the `formatter` module, and now lives at the crate root.

build/languages.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ helix_sum = "beb5afc"
55
name = "ada"
66
repo = "https://github.com/briot/tree-sitter-ada"
77
hash = "e8e2515"
8-
helix_override = true
98

109
[[languages]]
1110
name = "asm"
@@ -473,6 +472,7 @@ name = "rust"
473472
repo = "https://github.com/tree-sitter/tree-sitter-rust"
474473
hash = "6b7d1fc"
475474
aliases = ["rs"]
475+
helix_override = true
476476

477477
[[languages]]
478478
name = "scala"

examples/terminal_highlight.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ fn main() {
4040
// Create the Terminal formatter with both theme and stream
4141
let formatter = Terminal::new(theme, stream);
4242

43-
for line in source.lines() {
44-
highlighter
45-
.highlight_to_writer(language, &formatter, line, &mut io::stdout())
46-
.map_err(|e| io::Error::new(io::ErrorKind::Other, e.to_string()))?;
47-
println!();
48-
}
43+
highlighter.highlight_to_writer(
44+
language,
45+
&formatter,
46+
&source,
47+
&mut io::sink()
48+
);
4949

5050
println!();
5151

languages/ada/queries/highlights.scm

Lines changed: 59 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
"interface"
2727
"is"
2828
"limited"
29-
"null"
3029
"of"
3130
"others"
3231
"out"
@@ -40,23 +39,26 @@
4039
"until"
4140
"when"
4241
] @keyword
42+
[
43+
"null"
44+
] @constant.builtin
4345
[
4446
"aliased"
4547
"constant"
4648
"renames"
47-
] @storageclass
49+
] @keyword.storage
4850
[
4951
"mod"
5052
"new"
5153
"protected"
5254
"record"
5355
"subtype"
5456
"type"
55-
] @keyword.type
57+
] @type.builtin
5658
[
5759
"with"
5860
"use"
59-
] @include
61+
] @keyword.control.import
6062
[
6163
"body"
6264
"function"
@@ -71,89 +73,89 @@
7173
"not"
7274
"or"
7375
"xor"
74-
] @keyword.operator
76+
] @operator
7577
[
7678
"while"
7779
"loop"
7880
"for"
7981
"parallel"
8082
"reverse"
8183
"some"
82-
] @repeat
84+
] @kewyord.control.repeat
8385
[
8486
"return"
85-
] @keyword.return
87+
] @keyword.control.return
8688
[
8789
"case"
8890
"if"
8991
"else"
9092
"then"
9193
"elsif"
9294
"select"
93-
] @conditional
95+
] @keyword.control.conditional
9496
[
9597
"exception"
9698
"raise"
97-
] @exception
98-
(comment) @comment @spell
99-
(string_literal) @string
99+
] @keyword.control.exception
100+
(comment) @comment
101+
(string_literal) @string
100102
(character_literal) @string
101-
(numeric_literal) @number
103+
(numeric_literal) @constant.numeric
102104

103105
;; Highlight the name of subprograms
104-
(procedure_specification name: (_) @function)
105-
(function_specification name: (_) @function)
106-
(package_declaration name: (_) @function)
107-
(package_body name: (_) @function)
108-
(generic_instantiation name: (_) @function)
109-
(entry_declaration . (identifier) @function)
106+
(procedure_specification name: (_) @function.builtin)
107+
(function_specification name: (_) @function.builtin)
108+
(package_declaration name: (_) @function.builtin)
109+
(package_body name: (_) @function.builtin)
110+
(generic_instantiation name: (_) @function.builtin)
111+
(entry_declaration . (identifier) @function.builtin)
110112

111113
;; Some keywords should take different categories depending on the context
112-
(use_clause "use" @include "type" @include)
113-
(with_clause "private" @include)
114-
(with_clause "limited" @include)
114+
(use_clause "use" @keyword.control.import "type" @keyword.control.import)
115+
(with_clause "private" @keyword.control.import)
116+
(with_clause "limited" @keyword.control.import)
115117
(use_clause (_) @namespace)
116118
(with_clause (_) @namespace)
117119

118-
(loop_statement "end" @keyword.repeat)
119-
(if_statement "end" @conditional)
120-
(loop_parameter_specification "in" @keyword.repeat)
121-
(loop_parameter_specification "in" @keyword.repeat)
122-
(iterator_specification ["in" "of"] @keyword.repeat)
123-
(range_attribute_designator "range" @keyword.repeat)
120+
(loop_statement "end" @keyword.control.repeat)
121+
(if_statement "end" @keyword.control.conditional)
122+
(loop_parameter_specification "in" @keyword.control.repeat)
123+
(loop_parameter_specification "in" @keyword.control.repeat)
124+
(iterator_specification ["in" "of"] @keyword.control.repeat)
125+
(range_attribute_designator "range" @keyword.control.repeat)
124126

125-
(raise_statement "with" @exception)
127+
(raise_statement "with" @keyword.control.exception)
126128

127-
(gnatprep_declarative_if_statement) @preproc
128-
(gnatprep_if_statement) @preproc
129-
(gnatprep_identifier) @preproc
129+
(gnatprep_declarative_if_statement) @keyword.directive
130+
(gnatprep_if_statement) @keyword.directive
131+
(gnatprep_identifier) @keyword.directive
130132

131133
(subprogram_declaration "is" @keyword.function "abstract" @keyword.function)
132134
(aspect_specification "with" @keyword.function)
133135

134-
(full_type_declaration "is" @keyword.type)
135-
(subtype_declaration "is" @keyword.type)
136-
(record_definition "end" @keyword.type)
137-
(full_type_declaration (_ "access" @keyword.type))
138-
(array_type_definition "array" @keyword.type "of" @keyword.type)
139-
(access_to_object_definition "access" @keyword.type)
140-
(access_to_object_definition "access" @keyword.type
136+
(full_type_declaration "is" @type.builtin)
137+
(subtype_declaration "is" @type.builtin)
138+
(record_definition "end" @type.builtin)
139+
(full_type_declaration (_ "access" @type.builtin))
140+
(array_type_definition "array" @type.builtin "of" @type.builtin)
141+
(access_to_object_definition "access" @type.builtin)
142+
(access_to_object_definition "access" @type.builtin
141143
[
142-
(general_access_modifier "constant" @keyword.type)
143-
(general_access_modifier "all" @keyword.type)
144+
(general_access_modifier "constant" @type.builtin)
145+
(general_access_modifier "all" @type.builtin)
144146
]
145147
)
146-
(range_constraint "range" @keyword.type)
147-
(signed_integer_type_definition "range" @keyword.type)
148-
(index_subtype_definition "range" @keyword.type)
149-
(record_type_definition "abstract" @keyword.type)
150-
(record_type_definition "tagged" @keyword.type)
151-
(record_type_definition "limited" @keyword.type)
152-
(record_type_definition (record_definition "null" @keyword.type))
153-
(private_type_declaration "is" @keyword.type "private" @keyword.type)
154-
(private_type_declaration "tagged" @keyword.type)
155-
(private_type_declaration "limited" @keyword.type)
156-
(task_type_declaration "task" @keyword.type "is" @keyword.type)
148+
(range_constraint "range" @type.builtin)
149+
(signed_integer_type_definition "range" @type.builtin)
150+
(index_subtype_definition "range" @type.builtin)
151+
(record_type_definition "abstract" @type.builtin)
152+
(record_type_definition "tagged" @type.builtin)
153+
(record_type_definition "limited" @type.builtin)
154+
(record_type_definition (record_definition "null" @type.builtin))
155+
(private_type_declaration "is" @type.builtin "private" @type.builtin)
156+
(private_type_declaration "tagged" @type.builtin)
157+
(private_type_declaration "limited" @type.builtin)
158+
(task_type_declaration "task" @type.builtin "is" @type.builtin)
157159

158160
;; Gray the body of expression functions
159161
(expression_function_declaration
@@ -164,33 +166,11 @@
164166
(subprogram_declaration (aspect_specification) @attribute)
165167

166168
;; Highlight full subprogram specifications
167-
;(subprogram_body
168-
; [
169-
; (procedure_specification)
170-
; (function_specification)
171-
; ] @function.spec
172-
;)
173-
174-
((comment) @comment.documentation
175-
. [
176-
(entry_declaration)
177-
(subprogram_declaration)
178-
(parameter_specification)
179-
])
180-
181-
(compilation_unit
182-
. (comment) @comment.documentation)
183-
184-
(component_list
185-
(component_declaration)
186-
. (comment) @comment.documentation)
187-
188-
(enumeration_type_definition
189-
(identifier)
190-
. (comment) @comment.documentation)
169+
; (subprogram_body
170+
; [
171+
; (procedure_specification)
172+
; (function_specification)
173+
; ] @function.builtin.spec
174+
; )
191175

192-
;; Highlight errors in red. This is not very useful in practice, as text will
193-
;; be highlighted as user types, and the error could be elsewhere in the code.
194-
;; This also requires defining :hi @error guifg=Red for instance.
195-
(ERROR) @error
196176

languages/ada/queries/locals.scm

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,32 @@
1-
;; Better highlighting by referencing to the definition, for variable
2-
;; references. However, this is not yet supported by neovim
1+
;; Better highlighting by referencing to the definition, for variable references.
32
;; See https://tree-sitter.github.io/tree-sitter/syntax-highlighting#local-variables
43

5-
(compilation) @scope
6-
(package_declaration) @scope
7-
(package_body) @scope
8-
(subprogram_declaration) @scope
9-
(subprogram_body) @scope
10-
(block_statement) @scope
4+
(compilation) @local.scope
5+
(package_declaration) @local.scope
6+
(package_body) @local.scope
7+
(subprogram_declaration) @local.scope
8+
(subprogram_body) @local.scope
9+
(block_statement) @local.scope
1110

12-
(with_clause (_) @definition.import)
13-
(procedure_specification name: (_) @definition.function)
14-
(function_specification name: (_) @definition.function)
15-
(package_declaration name: (_) @definition.var)
16-
(package_body name: (_) @definition.var)
17-
(generic_instantiation . name: (_) @definition.var)
18-
(component_declaration . (identifier) @definition.var)
19-
(exception_declaration . (identifier) @definition.var)
20-
(formal_object_declaration . (identifier) @definition.var)
21-
(object_declaration . (identifier) @definition.var)
22-
(parameter_specification . (identifier) @definition.var)
23-
(full_type_declaration . (identifier) @definition.type)
24-
(private_type_declaration . (identifier) @definition.type)
25-
(private_extension_declaration . (identifier) @definition.type)
26-
(incomplete_type_declaration . (identifier) @definition.type)
27-
(protected_type_declaration . (identifier) @definition.type)
28-
(formal_complete_type_declaration . (identifier) @definition.type)
29-
(formal_incomplete_type_declaration . (identifier) @definition.type)
30-
(task_type_declaration . (identifier) @definition.type)
31-
(subtype_declaration . (identifier) @definition.type)
11+
(with_clause (_) @local.definition)
12+
(procedure_specification name: (_) @local.definition)
13+
(function_specification name: (_) @local.definition)
14+
(package_declaration name: (_) @local.definition)
15+
(package_body name: (_) @local.definition)
16+
(generic_instantiation . name: (_) @local.definition)
17+
(component_declaration . (identifier) @local.definition)
18+
(exception_declaration . (identifier) @local.definition)
19+
(formal_object_declaration . (identifier) @local.definition)
20+
(object_declaration . (identifier) @local.definition)
21+
(parameter_specification . (identifier) @local.definition)
22+
(full_type_declaration . (identifier) @local.definition)
23+
(private_type_declaration . (identifier) @local.definition)
24+
(private_extension_declaration . (identifier) @local.definition)
25+
(incomplete_type_declaration . (identifier) @local.definition)
26+
(protected_type_declaration . (identifier) @local.definition)
27+
(formal_complete_type_declaration . (identifier) @local.definition)
28+
(formal_incomplete_type_declaration . (identifier) @local.definition)
29+
(task_type_declaration . (identifier) @local.definition)
30+
(subtype_declaration . (identifier) @local.definition)
3231

33-
(identifier) @reference
32+
(identifier) @local.reference

0 commit comments

Comments
 (0)