Skip to content

Add LiquidHaskell annotation highlight #1321

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 12, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions haskell-font-lock.el
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,13 @@ font faces assigned as if respective mode was enabled."
;;;###autoload
(defface haskell-pragma-face
'((t :inherit font-lock-preprocessor-face))
"Face used to highlight Haskell pragmas."
"Face used to highlight Haskell pragmas ({-# ... #-})."
:group 'haskell-appearance)

;;;###autoload
(defface haskell-liquid-haskell-annotation-face
'((t :inherit haskell-pragma-face))
"Face used to highlight LiquidHaskell annotations ({-@ ... @-})."
:group 'haskell-appearance)

;;;###autoload
Expand Down Expand Up @@ -512,14 +518,23 @@ like ::, class, instance, data, newtype, type."
(equal (string-to-syntax "<") (syntax-after (point))))
'haskell-literate-comment-face)
;; Detect pragmas. A pragma is enclosed in special comment
;; delimeters {-# .. #-}.
;; delimiters {-# .. #-}.
((save-excursion
(goto-char (nth 8 state))
(and (looking-at-p "{-#")
(forward-comment 1)
(goto-char (- (point) 3))
(looking-at-p "#-}")))
'haskell-pragma-face)
;; Detect Liquid Haskell annotations enclosed in special comment
;; delimiters {-@ .. @-}.
((save-excursion
(goto-char (nth 8 state))
(and (looking-at-p "{-@")
(forward-comment 1)
(goto-char (- (point) 3))
(looking-at-p "@-}")))
'haskell-liquid-haskell-annotation-face)
;; Haddock comment start with either "-- [|^*$]" or "{- ?[|^*$]"
;; (note space optional for nested comments and mandatory for
;; double dash comments).
Expand Down
9 changes: 8 additions & 1 deletion tests/haskell-font-lock-tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@
"{-# pragma1 #-}"
"{-# non_pragma2 -}"
"{- non_pragma3 #-}"
"{-@ liquid_haskell @-}"
"{-@ non_liquid_haskell_2 -}"
"{- non_liquid_haskell_3 @-}"
)
'(("Cons0" "w" haskell-constructor-face)
("Comm1" "w" font-lock-comment-face)
Expand All @@ -168,7 +171,11 @@
("pragma1" "w" haskell-pragma-face)
("non_pragma2" "w" font-lock-comment-face)

("non_pragma3" "w" font-lock-comment-face))))
("non_pragma3" "w" font-lock-comment-face)
("liquid_haskell" "w" haskell-liquid-haskell-annotation-face)
("non_liquid_haskell_2" "w" font-lock-comment-face)

("non_liquid_haskell_3" "w" font-lock-comment-face))))


(ert-deftest haskell-syntactic-string-vs-comment-escape ()
Expand Down