Open MatthewGentoo opened 7 months ago
I've made a bit of progress and got most of the tests to pass. It looks like the changelog entry is accurate. Here is a patch for highlight.scm that makes all tests but functions.gleam pass (just shuffling things around).
diff --git a/queries/highlights.scm b/queries/highlights.scm
index 20f809f..0365244 100644
--- a/queries/highlights.scm
+++ b/queries/highlights.scm
@@ -7,22 +7,11 @@
(constant
name: (identifier) @constant)
-; Modules
-(module) @module
-(import alias: (identifier) @module)
-(remote_type_identifier
- module: (identifier) @module)
-(remote_constructor_name
- module: (identifier) @module)
-((field_access
- record: (identifier) @module
- field: (label) @function)
- (#is-not? local))
+; Variables
+(identifier) @variable
+(discard) @comment.unused
; Functions
-(unqualified_import (identifier) @function)
-(unqualified_import "type" (type_identifier) @type)
-(unqualified_import (type_identifier) @constructor)
(function
name: (identifier) @function)
(external_function
@@ -37,6 +26,18 @@
right: (identifier) @function)
(#is-not? local))
+; Modules
+(module) @module
+(import alias: (identifier) @module)
+(remote_type_identifier
+ module: (identifier) @module)
+(remote_constructor_name
+ module: (identifier) @module)
+((field_access
+ record: (identifier) @module
+ field: (label) @function)
+ (#is-not? local))
+
; "Properties"
; Assumed to be intended to refer to a name for a field; something that comes
; before ":" or after "."
@@ -59,12 +60,17 @@
; Data constructors
(constructor_name) @constructor
+; Import
+(unqualified_import (identifier) @function)
+(unqualified_import (type_identifier) @constructor)
+(unqualified_import "type" (type_identifier) @type)
+
; Literals
(string) @string
+(escape_sequence) @string.escape
((escape_sequence) @warning
; Deprecated in v0.33.0-rc2:
(#eq? @warning "\\e"))
-(escape_sequence) @string.escape
(bit_string_segment_option) @function.builtin
(integer) @number
(float) @number
@@ -75,10 +81,6 @@
((identifier) @error
(#match? @error "^(auto|delegate|derive|else|implement|macro|test|echo)$"))
-; Variables
-(identifier) @variable
-(discard) @comment.unused
-
; Keywords
[
(visibility_modifier) ; "pub"
@@ -99,12 +101,6 @@
"use"
] @keyword
-; Operators
-(binary_expression
- operator: _ @operator)
-(boolean_negation "!" @operator)
-(integer_negation "-" @operator)
-
; Punctuation
[
"("
@@ -128,3 +124,9 @@
"-"
"<-"
] @punctuation.delimiter
+
+; Operators
+(binary_expression
+ operator: _ @operator)
+(boolean_negation "!" @operator)
+(integer_negation "-" @operator)
The failure I'm stuck with is that function names in calls are being highlighted as property accesses, e.g. this test:
string.replace(in: original, each: pattern, with: replacement)
// <- module
// ^ function
✗ functions.gleam
Failure - row: 24, column: 12, expected highlight 'function', actual highlights: 'property'
It looks like the #is-not? local
check is causing the issue here. I'll take a closer look when I get a chance. This might be a bug upstream in tree-sitter
With
tree-sitter
0.20.6 as used by the CI, the tests all pass for me. However when upgrading to tree-sitter 0.21.0 and later, some of the highlight tests fail.There's something called out in the changelog of tree-sitter 0.21 which might be the issue: