Skip to content

Commit df272b6

Browse files
lastgosumattmeain
authored andcommitted
Add Haskell mode and highlights.scm
1 parent 4896a56 commit df272b6

File tree

2 files changed

+141
-0
lines changed

2 files changed

+141
-0
lines changed

queries/haskell/highlights.scm

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
;; ----------------------------------------------------------------------------
2+
;; Literals and comments
3+
4+
(integer) @number
5+
(exp_negation) @number
6+
(exp_literal (float)) @float
7+
(char) @character
8+
(string) @string
9+
10+
(con_unit) @symbol ; unit, as in ()
11+
12+
(comment) @comment
13+
14+
15+
;; ----------------------------------------------------------------------------
16+
;; Punctuation
17+
18+
[
19+
"("
20+
")"
21+
"{"
22+
"}"
23+
"["
24+
"]"
25+
] @punctuation.bracket
26+
27+
[
28+
(comma)
29+
";"
30+
] @punctuation.delimiter
31+
32+
33+
;; ----------------------------------------------------------------------------
34+
;; Keywords, operators, includes
35+
36+
[
37+
"forall"
38+
"∀"
39+
] @repeat
40+
41+
(pragma) @constant.macro
42+
43+
[
44+
"if"
45+
"then"
46+
"else"
47+
"case"
48+
"of"
49+
] @conditional
50+
51+
[
52+
"import"
53+
"qualified"
54+
"module"
55+
] @include
56+
57+
[
58+
(operator)
59+
(constructor_operator)
60+
(type_operator)
61+
(tycon_arrow)
62+
(qualified_module) ; grabs the `.` (dot), ex: import System.IO
63+
(all_names)
64+
(wildcard)
65+
"="
66+
"|"
67+
"::"
68+
"=>"
69+
"->"
70+
"<-"
71+
"\\"
72+
"`"
73+
"@"
74+
] @operator
75+
76+
(module) @namespace
77+
78+
[
79+
(where)
80+
"let"
81+
"in"
82+
"class"
83+
"instance"
84+
"data"
85+
"newtype"
86+
"family"
87+
"type"
88+
"as"
89+
"hiding"
90+
"deriving"
91+
"via"
92+
"stock"
93+
"anyclass"
94+
"do"
95+
"mdo"
96+
"rec"
97+
"infix"
98+
"infixl"
99+
"infixr"
100+
] @keyword
101+
102+
103+
;; ----------------------------------------------------------------------------
104+
;; Functions and variables
105+
106+
(variable) @variable
107+
(pat_wildcard) @variable
108+
109+
(signature name: (variable) @type)
110+
(function
111+
name: (variable) @function
112+
patterns: (patterns))
113+
((signature (fun)) . (function (variable) @function))
114+
((signature (context (fun))) . (function (variable) @function))
115+
((signature (forall (context (fun)))) . (function (variable) @function))
116+
117+
(exp_infix (variable) @operator) ; consider infix functions as operators
118+
119+
(exp_infix (exp_name) @function (#set! "priority" 101))
120+
(exp_apply . (exp_name (variable) @function))
121+
(exp_apply . (exp_name (qualified_variable (variable) @function)))
122+
123+
124+
;; ----------------------------------------------------------------------------
125+
;; Types
126+
127+
(type) @type
128+
(type_variable) @type
129+
130+
(constructor) @constructor
131+
132+
; True or False
133+
((constructor) @_bool (#match? @_bool "(True|False)")) @boolean
134+
135+
136+
;; ----------------------------------------------------------------------------
137+
;; Quasi-quotes
138+
139+
(quoter) @function
140+
; Highlighting of quasiquote_body is handled by injections.scm

tree-sitter-langs.el

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ See `tree-sitter-langs-repos'."
109109
(elm-mode . elm)
110110
(elixir-mode . elixir)
111111
(go-mode . go)
112+
(haskell-mode . haskell)
112113
(hcl-mode . hcl)
113114
(terraform-mode . hcl)
114115
(html-mode . html)

0 commit comments

Comments
 (0)