on master help sign in
Update PureScript grammar (#8712)
a98ad13postsolar
languages.toml+1−1
@@ -1142,7 +1142,7 @@ formatter = { command = "purs-tidy", args = ["format"] }
1142
1142
1143[[grammar]]
1143[[grammar]]
1144name = "purescript"
1144name = "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" }
1146
1146
1147[[language]]
1147[[language]]
1148name = "zig"
1148name = "zig"
runtime/queries/purescript/highlights.scm+31−7
@@ -3,15 +3,13 @@
3
3
4 (integer) @constant.numeric.integer
4 (integer) @constant.numeric.integer
5 (exp_negation) @constant.numeric.integer
5 (exp_negation) @constant.numeric.integer
6− (exp_literal (float)) @constant.numeric.float
6+ (exp_literal (number)) @constant.numeric.float
7 (char) @constant.character
7 (char) @constant.character
8 [
8 [
9 (string)
9 (string)
10 (triple_quote_string)
10 (triple_quote_string)
11 ] @string
11 ] @string
12
12
13− (con_unit) @constant.builtin ; unit, as in ()
14−
15 (comment) @comment
13 (comment) @comment
16
14
17
15
@@ -36,6 +34,10 @@
36; ----------------------------------------------------------------------------
34; ----------------------------------------------------------------------------
37; Keywords, operators, includes
35; Keywords, operators, includes
38
36
37+ ; This needs to come before the other "else" in
38+ ; order to be highlighted correctly
39+ (class_instance "else" @keyword)
40+
39 [
41 [
40 "if"
42 "if"
41 "then"
43 "then"
@@ -53,15 +55,20 @@
53 (operator)
55 (operator)
54 (constructor_operator)
56 (constructor_operator)
55 (type_operator)
57 (type_operator)
56− (tycon_arrow)
57 (qualified_module) ; grabs the `.` (dot), ex: import System.IO
58 (qualified_module) ; grabs the `.` (dot), ex: import System.IO
58 (all_names)
59 (all_names)
60+
61+ ; `_` wildcards in if-then-else and case-of expressions,
62+ ; as well as record updates and operator sections
63+ (wildcard)
59 "="
64 "="
60 "|"
65 "|"
61 "::"
66 "::"
62 "∷"
67 "∷"
63 "=>"
68 "=>"
64 "⇒"
69 "⇒"
70+ "<="
71+ "⇐"
65 "->"
72 "->"
66 "→"
73 "→"
67 "<-"
74 "<-"
@@ -89,6 +96,7 @@
89 "newtype"
96 "newtype"
90 "type"
97 "type"
91 "as"
98 "as"
99+ "hiding"
92 "do"
100 "do"
93 "ado"
101 "ado"
94 "forall"
102 "forall"
@@ -98,24 +106,40 @@
98 "infixr"
106 "infixr"
99 ] @keyword
107 ] @keyword
100
108
109+ (type_role_declaration
110+ "role" @keyword
111+ role: (type_role) @keyword)
112+
113+ (hole) @label
101
114
102; ----------------------------------------------------------------------------
115; ----------------------------------------------------------------------------
103; Functions and variables
116; Functions and variables
104
117
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+
105 (signature name: (variable) @type)
123 (signature name: (variable) @type)
106 (function name: (variable) @function)
124 (function name: (variable) @function)
125+ (class_instance (instance_name) @function)
126+ (derive_declaration (instance_name) @function)
107
127
108 ; true or false
128 ; true or false
109((variable) @constant.builtin.boolean
129((variable) @constant.builtin.boolean
110 (#match? @constant.builtin.boolean "^(true|false)$"))
130 (#match? @constant.builtin.boolean "^(true|false)$"))
111
131
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)))
113
138
114− (exp_infix (variable) @operator) ; consider infix functions as operators
139+ (variable) @variable
115
140
116 ("@" @namespace) ; "as" pattern operator, e.g. x@Constructor
141 ("@" @namespace) ; "as" pattern operator, e.g. x@Constructor
117
142
118−
119; ----------------------------------------------------------------------------
143; ----------------------------------------------------------------------------
120; Types
144; Types
121
145