aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Jakobi <marc.jakobi@tiko.energy>2023-09-26 22:20:59 +0200
committerChristian Clason <c.clason@uni-graz.at>2023-09-27 17:18:14 +0200
commitec0e344f6ee1d910fe63a8bbce5380c42af47135 (patch)
treeb419811fceb3af41b96a69c06eee82774ab1658b
parentUpdate parsers: git_config, gleam, wing (diff)
downloadnvim-treesitter-ec0e344f6ee1d910fe63a8bbce5380c42af47135.tar
nvim-treesitter-ec0e344f6ee1d910fe63a8bbce5380c42af47135.tar.gz
nvim-treesitter-ec0e344f6ee1d910fe63a8bbce5380c42af47135.tar.bz2
nvim-treesitter-ec0e344f6ee1d910fe63a8bbce5380c42af47135.tar.lz
nvim-treesitter-ec0e344f6ee1d910fe63a8bbce5380c42af47135.tar.xz
nvim-treesitter-ec0e344f6ee1d910fe63a8bbce5380c42af47135.tar.zst
nvim-treesitter-ec0e344f6ee1d910fe63a8bbce5380c42af47135.zip
feat(highlights): some haskell additions
- Re-add (module) @namespace - Exception handling - Debugging - `otherwise` = boolean `True` - `qq` string quasiquotes - Documentation comments (draft) - Function/lambda parameters - Remove recently added @ (already defined as an operator)
-rw-r--r--queries/haskell/highlights.scm110
1 files changed, 105 insertions, 5 deletions
diff --git a/queries/haskell/highlights.scm b/queries/haskell/highlights.scm
index 18038e079..5bd8d1b34 100644
--- a/queries/haskell/highlights.scm
+++ b/queries/haskell/highlights.scm
@@ -1,4 +1,16 @@
;; ----------------------------------------------------------------------------
+;; Parameters
+
+;; NOTE: These are at the top, so that they have low priority,
+;; and don't override destructured parameters
+
+(function
+ patterns: (patterns (pat_name) @parameter))
+
+(exp_lambda
+ (pat_name) @parameter)
+
+;; ----------------------------------------------------------------------------
;; Literals and comments
(integer) @number
@@ -11,6 +23,31 @@
(comment) @comment
+; FIXME: The below documentation comment queries are inefficient
+; and need to be anchored, using something like
+; ((comment) @_first . (comment)+ @comment.documentation)
+; once https://github.com/neovim/neovim/pull/24738 has been merged.
+;
+; ((comment) @comment.documentation
+; (#lua-match? @comment.documentation "^-- |"))
+;
+; ((comment) @_first @comment.documentation
+; (comment) @comment.documentation
+; (#lua-match? @_first "^-- |"))
+;
+; ((comment) @comment.documentation
+; (#lua-match? @comment.documentation "^-- %^"))
+;
+; ((comment) @_first @comment.documentation
+; (comment) @comment.documentation
+; (#lua-match? @_first "^-- %^"))
+;
+; ((comment) @comment.documentation
+; (#lua-match? @comment.documentation "^{-"))
+;
+; ((comment) @_first @comment.documentation
+; (comment) @comment.documentation
+; (#lua-match? @_first "^{-"))
;; ----------------------------------------------------------------------------
;; Punctuation
@@ -77,6 +114,8 @@
"@"
] @operator
+
+(module) @namespace
(qualified_module (module) @constructor)
(qualified_type (module) @namespace)
(qualified_variable (module) @namespace)
@@ -136,9 +175,6 @@
(exp_apply . (exp_name (variable) @function.call))
(exp_apply . (exp_name (qualified_variable (variable) @function.call)))
-("@" @namespace) ; "as" pattern operator, e.g. x@Constructor
-
-
;; ----------------------------------------------------------------------------
;; Types
@@ -150,13 +186,77 @@
; True or False
((constructor) @boolean (#any-of? @boolean "True" "False"))
-
+; otherwise (= True)
+((variable) @boolean
+ (#eq? @boolean "otherwise"))
;; ----------------------------------------------------------------------------
;; Quasi-quotes
(quoter) @function.call
-; Highlighting of quasiquote_body is handled by injections.scm
+
+(quasiquote
+ (quoter) @_name (#eq? @_name "qq")
+ (quasiquote_body) @string)
+
+; Highlighting of quasiquote_body for other languages is handled by injections.scm
+
+;; ----------------------------------------------------------------------------
+;; Exceptions/error handling
+
+((variable) @exception
+ (#any-of? @exception
+ "error"
+ "undefined"
+ "try"
+ "tryJust"
+ "tryAny"
+ "catch"
+ "catches"
+ "catchJust"
+ "handle"
+ "handleJust"
+ "throw"
+ "throwIO"
+ "throwTo"
+ "throwError"
+ "ioError"
+ "mask"
+ "mask_"
+ "uninterruptibleMask"
+ "uninterruptibleMask_"
+ "bracket"
+ "bracket_"
+ "bracketOnErrorSource"
+ "finally"
+ "onException"))
+
+;; ----------------------------------------------------------------------------
+;; Debugging
+((variable) @debug
+ (#any-of? @debug
+ "trace"
+ "traceId"
+ "traceShow"
+ "traceShowId"
+ "traceWith"
+ "traceShowWith"
+ "traceStack"
+ "traceIO"
+ "traceM"
+ "traceShowM"
+ "traceEvent"
+ "traceEventWith"
+ "traceEventIO"
+ "flushEventLog"
+ "traceMarker"
+ "traceMarkerIO"))
+
+
+;; ----------------------------------------------------------------------------
+;; Record fields
+(record_fields (field (variable) @field))
+
;; ----------------------------------------------------------------------------
;; Spell checking