feat(haskell): improve highlight query

Co-authored-by: Farbod Salamat-Zadeh <12140044+farbodsz@users.noreply.github.com>
This commit is contained in:
elianiva 2021-06-19 05:09:06 +07:00 committed by Stephan Seitz
parent 684b74bea1
commit f9bce468a0

View file

@ -1,17 +1,36 @@
;; ----------------------------------------------------------------------------
;; Literals and comments
(integer) @number (integer) @number
(exp_negation) @number
(exp_literal (float)) @float (exp_literal (float)) @float
(char) @character (char) @character
(string) @string (string) @string
(variable) @variable (con_unit) @symbol ; unit, as in ()
(con_unit) @symbol
(comment) @comment (comment) @comment
(function name: (variable) @function) ;; ----------------------------------------------------------------------------
;; Punctuation
[
"("
")"
"{"
"}"
"["
"]"
] @punctuation.bracket
[
(comma)
";"
] @punctuation.delimiter
;; ----------------------------------------------------------------------------
;; Keywords, operators, includes
[ [
"forall" "forall"
@ -24,38 +43,40 @@
"if" "if"
"then" "then"
"else" "else"
"case"
"of"
] @conditional ] @conditional
[
(constructor)
(module)
] @constructor
;; True or False
((constructor) @_bool (#match? @_bool "(True|False)")) @boolean
(signature name: (variable) @type)
(constraint class: (class_name (type)) @type)
(class (class_head class: (class_name (type)) @type))
(instance (instance_head class: (class_name (type)) @type))
[
(type)
] @type
[
(qualified_module) ;; grabs the `.` (dot), ex: import System.IO
(tycon_arrow)
(operator)
(constructor_operator)
"::"
] @operator
[ [
"import" "import"
"qualified"
"module" "module"
] @include ] @include
[
(operator)
(constructor_operator)
(type_operator)
(tycon_arrow)
(qualified_module) ; grabs the `.` (dot), ex: import System.IO
(all_names)
(wildcard)
"="
"|"
"::"
"=>"
"->"
"<-"
"\\"
"`"
"@"
] @operator
(qualified_module (module) @constructor)
(qualified_type (module) @namespace)
(qualified_variable (module) @namespace)
(import (module) @namespace)
[ [
(where) (where)
"let" "let"
@ -66,8 +87,8 @@
"newtype" "newtype"
"family" "family"
"type" "type"
"qualified"
"as" "as"
"hiding"
"deriving" "deriving"
"via" "via"
"stock" "stock"
@ -77,15 +98,27 @@
"rec" "rec"
] @keyword ] @keyword
[
"("
")"
"{"
"}"
"["
"]"
] @punctuation.bracket
; [ ;; ----------------------------------------------------------------------------
; "," ;; Functions and variables
; ] @punctuation.delimiter
(signature name: (variable) @type)
(function name: (variable) @function)
(variable) @variable
"_" @punctuation.special
(exp_infix (variable) @operator) ; consider infix functions as operators
("@" @namespace) ; "as" pattern operator, e.g. x@Constructor
;; ----------------------------------------------------------------------------
;; Types
(type) @type
(constructor) @constructor
; True or False
((constructor) @_bool (#match? @_bool "(True|False)")) @boolean