highlights.scm

  1;; Copyright 2022 nvim-treesitter
  2;;
  3;; Licensed under the Apache License, Version 2.0 (the "License");
  4;; you may not use this file except in compliance with the License.
  5;; You may obtain a copy of the License at
  6;;
  7;;     http://www.apache.org/licenses/LICENSE-2.0
  8;;
  9;; Unless required by applicable law or agreed to in writing, software
 10;; distributed under the License is distributed on an "AS IS" BASIS,
 11;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12;; See the License for the specific language governing permissions and
 13;; limitations under the License.
 14
 15;; ----------------------------------------------------------------------------
 16;; Literals and comments
 17
 18(integer) @number
 19(exp_negation) @number
 20(exp_literal (float)) @float
 21(char) @string
 22(string) @string
 23
 24(con_unit) @symbol  ; unit, as in ()
 25
 26(comment) @comment
 27
 28
 29;; ----------------------------------------------------------------------------
 30;; Punctuation
 31
 32[
 33  "("
 34  ")"
 35  "{"
 36  "}"
 37  "["
 38  "]"
 39] @punctuation.bracket
 40
 41[
 42  (comma)
 43  ";"
 44] @punctuation.delimiter
 45
 46
 47;; ----------------------------------------------------------------------------
 48;; Keywords, operators, includes
 49
 50[
 51  "forall"
 52  "∀"
 53] @keyword
 54
 55(pragma) @constant
 56
 57[
 58  "if"
 59  "then"
 60  "else"
 61  "case"
 62  "of"
 63] @keyword
 64
 65(exp_lambda_cases "\\" ("cases" @variant))
 66
 67[
 68  "import"
 69  "qualified"
 70  "module"
 71] @keyword
 72
 73[
 74  (operator)
 75  (constructor_operator)
 76  (type_operator)
 77  (tycon_arrow)
 78  (qualified_module)  ; grabs the `.` (dot), ex: import System.IO
 79  (all_names)
 80  (wildcard)
 81  "="
 82  "|"
 83  "::"
 84  "=>"
 85  "->"
 86  "<-"
 87  "\\"
 88  "`"
 89  "@"
 90] @operator
 91
 92(module) @title
 93
 94[
 95  (where)
 96  "let"
 97  "in"
 98  "class"
 99  "instance"
100  "data"
101  "newtype"
102  "family"
103  "type"
104  "as"
105  "hiding"
106  "deriving"
107  "via"
108  "stock"
109  "anyclass"
110  "do"
111  "mdo"
112  "rec"
113  "infix"
114  "infixl"
115  "infixr"
116] @keyword
117
118
119;; ----------------------------------------------------------------------------
120;; Functions and variables
121
122(variable) @variable
123(pat_wildcard) @variable
124
125(signature name: (variable) @type)
126(function
127  name: (variable) @function
128  patterns: (patterns))
129((signature (fun)) . (function (variable) @function))
130((signature (context (fun))) . (function (variable) @function))
131((signature (forall (context (fun)))) . (function (variable) @function))
132
133(exp_infix (variable) @operator)  ; consider infix functions as operators
134
135(exp_infix (exp_name) @function (#set! "priority" 101))
136(exp_apply . (exp_name (variable) @function))
137(exp_apply . (exp_name (qualified_variable (variable) @function)))
138
139
140;; ----------------------------------------------------------------------------
141;; Types
142
143(type) @type
144(type_variable) @type
145
146(constructor) @constructor
147
148; True or False
149((constructor) @_bool (#match? @_bool "(True|False)")) @boolean
150
151
152;; ----------------------------------------------------------------------------
153;; Quasi-quotes
154
155(quoter) @function
156; Highlighting of quasiquote_body is handled by injections.scm