Skip to content

Commit a98ad13

Browse files
authored
Update PureScript grammar (#8712)
1 parent 2fddc2a commit a98ad13

File tree

2 files changed

+32
-8
lines changed

2 files changed

+32
-8
lines changed

languages.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1142,7 +1142,7 @@ formatter = { command = "purs-tidy", args = ["format"] }
11421142

11431143
[[grammar]]
11441144
name = "purescript"
1145-
source = { git = "https://github.com/maskhjarna/tree-sitter-purescript", rev = "0e36a885a941078bf40e559026be425764dc27bf" }
1145+
source = { git = "https://github.com/postsolar/tree-sitter-purescript", rev = "593193b9bf0f46d5eee708a4e53044d2a9054897" }
11461146

11471147
[[language]]
11481148
name = "zig"

runtime/queries/purescript/highlights.scm

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,13 @@
33

44
(integer) @constant.numeric.integer
55
(exp_negation) @constant.numeric.integer
6-
(exp_literal (float)) @constant.numeric.float
6+
(exp_literal (number)) @constant.numeric.float
77
(char) @constant.character
88
[
99
(string)
1010
(triple_quote_string)
1111
] @string
1212

13-
(con_unit) @constant.builtin ; unit, as in ()
14-
1513
(comment) @comment
1614

1715

@@ -36,6 +34,10 @@
3634
; ----------------------------------------------------------------------------
3735
; Keywords, operators, includes
3836

37+
; This needs to come before the other "else" in
38+
; order to be highlighted correctly
39+
(class_instance "else" @keyword)
40+
3941
[
4042
"if"
4143
"then"
@@ -53,15 +55,20 @@
5355
(operator)
5456
(constructor_operator)
5557
(type_operator)
56-
(tycon_arrow)
5758
(qualified_module) ; grabs the `.` (dot), ex: import System.IO
5859
(all_names)
60+
61+
; `_` wildcards in if-then-else and case-of expressions,
62+
; as well as record updates and operator sections
63+
(wildcard)
5964
"="
6065
"|"
6166
"::"
6267
"∷"
6368
"=>"
6469
"⇒"
70+
"<="
71+
"⇐"
6572
"->"
6673
"→"
6774
"<-"
@@ -89,6 +96,7 @@
8996
"newtype"
9097
"type"
9198
"as"
99+
"hiding"
92100
"do"
93101
"ado"
94102
"forall"
@@ -98,24 +106,40 @@
98106
"infixr"
99107
] @keyword
100108

109+
(type_role_declaration
110+
"role" @keyword
111+
role: (type_role) @keyword)
112+
113+
(hole) @label
101114

102115
; ----------------------------------------------------------------------------
103116
; Functions and variables
104117

118+
(row_field (field_name) @variable.other.member)
119+
(record_field (field_name) @variable.other.member)
120+
(record_accessor (variable) @variable.other.member)
121+
(exp_record_access (variable) @variable.other.member)
122+
105123
(signature name: (variable) @type)
106124
(function name: (variable) @function)
125+
(class_instance (instance_name) @function)
126+
(derive_declaration (instance_name) @function)
107127

108128
; true or false
109129
((variable) @constant.builtin.boolean
110130
(#match? @constant.builtin.boolean "^(true|false)$"))
111131

112-
(variable) @variable
132+
; The former one works for `tree-sitter highlight` but not in Helix/Kakoune.
133+
; The latter two work in Helix (but not Kakoune) and are a good compromise between not highlighting anything at all
134+
; as an operator and leaving it to the child nodes, and highlighting everything as an operator.
135+
(exp_ticked (_) @operator)
136+
(exp_ticked (exp_name (variable) @operator))
137+
(exp_ticked (exp_name (qualified_variable (variable) @operator)))
113138

114-
(exp_infix (variable) @operator) ; consider infix functions as operators
139+
(variable) @variable
115140

116141
("@" @namespace) ; "as" pattern operator, e.g. x@Constructor
117142

118-
119143
; ----------------------------------------------------------------------------
120144
; Types
121145

0 commit comments

Comments
 (0)