Skip to content

Commit

Permalink
v0.11.1 (resolve #25)
Browse files Browse the repository at this point in the history
  • Loading branch information
Colonial-Dev committed Sep 15, 2024
1 parent 1d512bb commit d96244a
Show file tree
Hide file tree
Showing 14 changed files with 548 additions and 830 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
### 0.11.1
- (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.)
- (Bugfix) - example terminal highlighter now works properly.
- (Bugfix) - updated Rust and Ada highlighting queries to behave properly.

### 0.11.0
- (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.
- The `theme` module has been hoisted out of the `formatter` module, and now lives at the crate root.
Expand Down
2 changes: 1 addition & 1 deletion build/languages.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ helix_sum = "beb5afc"
name = "ada"
repo = "https://github.com/briot/tree-sitter-ada"
hash = "e8e2515"
helix_override = true

[[languages]]
name = "asm"
Expand Down Expand Up @@ -473,6 +472,7 @@ name = "rust"
repo = "https://github.com/tree-sitter/tree-sitter-rust"
hash = "6b7d1fc"
aliases = ["rs"]
helix_override = true

[[languages]]
name = "scala"
Expand Down
12 changes: 6 additions & 6 deletions examples/terminal_highlight.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ fn main() {
// Create the Terminal formatter with both theme and stream
let formatter = Terminal::new(theme, stream);

for line in source.lines() {
highlighter
.highlight_to_writer(language, &formatter, line, &mut io::stdout())
.map_err(|e| io::Error::new(io::ErrorKind::Other, e.to_string()))?;
println!();
}
highlighter.highlight_to_writer(
language,
&formatter,
&source,
&mut io::sink()
);

println!();

Expand Down
138 changes: 59 additions & 79 deletions languages/ada/queries/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
"interface"
"is"
"limited"
"null"
"of"
"others"
"out"
Expand All @@ -40,23 +39,26 @@
"until"
"when"
] @keyword
[
"null"
] @constant.builtin
[
"aliased"
"constant"
"renames"
] @storageclass
] @keyword.storage
[
"mod"
"new"
"protected"
"record"
"subtype"
"type"
] @keyword.type
] @type.builtin
[
"with"
"use"
] @include
] @keyword.control.import
[
"body"
"function"
Expand All @@ -71,89 +73,89 @@
"not"
"or"
"xor"
] @keyword.operator
] @operator
[
"while"
"loop"
"for"
"parallel"
"reverse"
"some"
] @repeat
] @kewyord.control.repeat
[
"return"
] @keyword.return
] @keyword.control.return
[
"case"
"if"
"else"
"then"
"elsif"
"select"
] @conditional
] @keyword.control.conditional
[
"exception"
"raise"
] @exception
(comment) @comment @spell
(string_literal) @string
] @keyword.control.exception
(comment) @comment
(string_literal) @string
(character_literal) @string
(numeric_literal) @number
(numeric_literal) @constant.numeric

;; Highlight the name of subprograms
(procedure_specification name: (_) @function)
(function_specification name: (_) @function)
(package_declaration name: (_) @function)
(package_body name: (_) @function)
(generic_instantiation name: (_) @function)
(entry_declaration . (identifier) @function)
(procedure_specification name: (_) @function.builtin)
(function_specification name: (_) @function.builtin)
(package_declaration name: (_) @function.builtin)
(package_body name: (_) @function.builtin)
(generic_instantiation name: (_) @function.builtin)
(entry_declaration . (identifier) @function.builtin)

;; Some keywords should take different categories depending on the context
(use_clause "use" @include "type" @include)
(with_clause "private" @include)
(with_clause "limited" @include)
(use_clause "use" @keyword.control.import "type" @keyword.control.import)
(with_clause "private" @keyword.control.import)
(with_clause "limited" @keyword.control.import)
(use_clause (_) @namespace)
(with_clause (_) @namespace)

(loop_statement "end" @keyword.repeat)
(if_statement "end" @conditional)
(loop_parameter_specification "in" @keyword.repeat)
(loop_parameter_specification "in" @keyword.repeat)
(iterator_specification ["in" "of"] @keyword.repeat)
(range_attribute_designator "range" @keyword.repeat)
(loop_statement "end" @keyword.control.repeat)
(if_statement "end" @keyword.control.conditional)
(loop_parameter_specification "in" @keyword.control.repeat)
(loop_parameter_specification "in" @keyword.control.repeat)
(iterator_specification ["in" "of"] @keyword.control.repeat)
(range_attribute_designator "range" @keyword.control.repeat)

(raise_statement "with" @exception)
(raise_statement "with" @keyword.control.exception)

(gnatprep_declarative_if_statement) @preproc
(gnatprep_if_statement) @preproc
(gnatprep_identifier) @preproc
(gnatprep_declarative_if_statement) @keyword.directive
(gnatprep_if_statement) @keyword.directive
(gnatprep_identifier) @keyword.directive

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

(full_type_declaration "is" @keyword.type)
(subtype_declaration "is" @keyword.type)
(record_definition "end" @keyword.type)
(full_type_declaration (_ "access" @keyword.type))
(array_type_definition "array" @keyword.type "of" @keyword.type)
(access_to_object_definition "access" @keyword.type)
(access_to_object_definition "access" @keyword.type
(full_type_declaration "is" @type.builtin)
(subtype_declaration "is" @type.builtin)
(record_definition "end" @type.builtin)
(full_type_declaration (_ "access" @type.builtin))
(array_type_definition "array" @type.builtin "of" @type.builtin)
(access_to_object_definition "access" @type.builtin)
(access_to_object_definition "access" @type.builtin
[
(general_access_modifier "constant" @keyword.type)
(general_access_modifier "all" @keyword.type)
(general_access_modifier "constant" @type.builtin)
(general_access_modifier "all" @type.builtin)
]
)
(range_constraint "range" @keyword.type)
(signed_integer_type_definition "range" @keyword.type)
(index_subtype_definition "range" @keyword.type)
(record_type_definition "abstract" @keyword.type)
(record_type_definition "tagged" @keyword.type)
(record_type_definition "limited" @keyword.type)
(record_type_definition (record_definition "null" @keyword.type))
(private_type_declaration "is" @keyword.type "private" @keyword.type)
(private_type_declaration "tagged" @keyword.type)
(private_type_declaration "limited" @keyword.type)
(task_type_declaration "task" @keyword.type "is" @keyword.type)
(range_constraint "range" @type.builtin)
(signed_integer_type_definition "range" @type.builtin)
(index_subtype_definition "range" @type.builtin)
(record_type_definition "abstract" @type.builtin)
(record_type_definition "tagged" @type.builtin)
(record_type_definition "limited" @type.builtin)
(record_type_definition (record_definition "null" @type.builtin))
(private_type_declaration "is" @type.builtin "private" @type.builtin)
(private_type_declaration "tagged" @type.builtin)
(private_type_declaration "limited" @type.builtin)
(task_type_declaration "task" @type.builtin "is" @type.builtin)

;; Gray the body of expression functions
(expression_function_declaration
Expand All @@ -164,33 +166,11 @@
(subprogram_declaration (aspect_specification) @attribute)

;; Highlight full subprogram specifications
;(subprogram_body
; [
; (procedure_specification)
; (function_specification)
; ] @function.spec
;)

((comment) @comment.documentation
. [
(entry_declaration)
(subprogram_declaration)
(parameter_specification)
])

(compilation_unit
. (comment) @comment.documentation)

(component_list
(component_declaration)
. (comment) @comment.documentation)

(enumeration_type_definition
(identifier)
. (comment) @comment.documentation)
; (subprogram_body
; [
; (procedure_specification)
; (function_specification)
; ] @function.builtin.spec
; )

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

57 changes: 28 additions & 29 deletions languages/ada/queries/locals.scm
Original file line number Diff line number Diff line change
@@ -1,33 +1,32 @@
;; Better highlighting by referencing to the definition, for variable
;; references. However, this is not yet supported by neovim
;; Better highlighting by referencing to the definition, for variable references.
;; See https://tree-sitter.github.io/tree-sitter/syntax-highlighting#local-variables

(compilation) @scope
(package_declaration) @scope
(package_body) @scope
(subprogram_declaration) @scope
(subprogram_body) @scope
(block_statement) @scope
(compilation) @local.scope
(package_declaration) @local.scope
(package_body) @local.scope
(subprogram_declaration) @local.scope
(subprogram_body) @local.scope
(block_statement) @local.scope

(with_clause (_) @definition.import)
(procedure_specification name: (_) @definition.function)
(function_specification name: (_) @definition.function)
(package_declaration name: (_) @definition.var)
(package_body name: (_) @definition.var)
(generic_instantiation . name: (_) @definition.var)
(component_declaration . (identifier) @definition.var)
(exception_declaration . (identifier) @definition.var)
(formal_object_declaration . (identifier) @definition.var)
(object_declaration . (identifier) @definition.var)
(parameter_specification . (identifier) @definition.var)
(full_type_declaration . (identifier) @definition.type)
(private_type_declaration . (identifier) @definition.type)
(private_extension_declaration . (identifier) @definition.type)
(incomplete_type_declaration . (identifier) @definition.type)
(protected_type_declaration . (identifier) @definition.type)
(formal_complete_type_declaration . (identifier) @definition.type)
(formal_incomplete_type_declaration . (identifier) @definition.type)
(task_type_declaration . (identifier) @definition.type)
(subtype_declaration . (identifier) @definition.type)
(with_clause (_) @local.definition)
(procedure_specification name: (_) @local.definition)
(function_specification name: (_) @local.definition)
(package_declaration name: (_) @local.definition)
(package_body name: (_) @local.definition)
(generic_instantiation . name: (_) @local.definition)
(component_declaration . (identifier) @local.definition)
(exception_declaration . (identifier) @local.definition)
(formal_object_declaration . (identifier) @local.definition)
(object_declaration . (identifier) @local.definition)
(parameter_specification . (identifier) @local.definition)
(full_type_declaration . (identifier) @local.definition)
(private_type_declaration . (identifier) @local.definition)
(private_extension_declaration . (identifier) @local.definition)
(incomplete_type_declaration . (identifier) @local.definition)
(protected_type_declaration . (identifier) @local.definition)
(formal_complete_type_declaration . (identifier) @local.definition)
(formal_incomplete_type_declaration . (identifier) @local.definition)
(task_type_declaration . (identifier) @local.definition)
(subtype_declaration . (identifier) @local.definition)

(identifier) @reference
(identifier) @local.reference
Loading

0 comments on commit d96244a

Please sign in to comment.