Skip to content

Commit fa57f91

Browse files
committed
Merge pull request #1321 from gracjan/pr-liquid
Add LiquidHaskell annotation highlight
2 parents 108acd1 + 25764a6 commit fa57f91

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

haskell-font-lock.el

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,13 @@ font faces assigned as if respective mode was enabled."
155155
;;;###autoload
156156
(defface haskell-pragma-face
157157
'((t :inherit font-lock-preprocessor-face))
158-
"Face used to highlight Haskell pragmas."
158+
"Face used to highlight Haskell pragmas ({-# ... #-})."
159+
:group 'haskell-appearance)
160+
161+
;;;###autoload
162+
(defface haskell-liquid-haskell-annotation-face
163+
'((t :inherit haskell-pragma-face))
164+
"Face used to highlight LiquidHaskell annotations ({-@ ... @-})."
159165
:group 'haskell-appearance)
160166

161167
;;;###autoload
@@ -512,14 +518,23 @@ like ::, class, instance, data, newtype, type."
512518
(equal (string-to-syntax "<") (syntax-after (point))))
513519
'haskell-literate-comment-face)
514520
;; Detect pragmas. A pragma is enclosed in special comment
515-
;; delimeters {-# .. #-}.
521+
;; delimiters {-# .. #-}.
516522
((save-excursion
517523
(goto-char (nth 8 state))
518524
(and (looking-at-p "{-#")
519525
(forward-comment 1)
520526
(goto-char (- (point) 3))
521527
(looking-at-p "#-}")))
522528
'haskell-pragma-face)
529+
;; Detect Liquid Haskell annotations enclosed in special comment
530+
;; delimiters {-@ .. @-}.
531+
((save-excursion
532+
(goto-char (nth 8 state))
533+
(and (looking-at-p "{-@")
534+
(forward-comment 1)
535+
(goto-char (- (point) 3))
536+
(looking-at-p "@-}")))
537+
'haskell-liquid-haskell-annotation-face)
523538
;; Haddock comment start with either "-- [|^*$]" or "{- ?[|^*$]"
524539
;; (note space optional for nested comments and mandatory for
525540
;; double dash comments).

tests/haskell-font-lock-tests.el

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,9 @@
155155
"{-# pragma1 #-}"
156156
"{-# non_pragma2 -}"
157157
"{- non_pragma3 #-}"
158+
"{-@ liquid_haskell @-}"
159+
"{-@ non_liquid_haskell_2 -}"
160+
"{- non_liquid_haskell_3 @-}"
158161
)
159162
'(("Cons0" "w" haskell-constructor-face)
160163
("Comm1" "w" font-lock-comment-face)
@@ -168,7 +171,11 @@
168171
("pragma1" "w" haskell-pragma-face)
169172
("non_pragma2" "w" font-lock-comment-face)
170173

171-
("non_pragma3" "w" font-lock-comment-face))))
174+
("non_pragma3" "w" font-lock-comment-face)
175+
("liquid_haskell" "w" haskell-liquid-haskell-annotation-face)
176+
("non_liquid_haskell_2" "w" font-lock-comment-face)
177+
178+
("non_liquid_haskell_3" "w" font-lock-comment-face))))
172179

173180

174181
(ert-deftest haskell-syntactic-string-vs-comment-escape ()

0 commit comments

Comments
 (0)