Skip to content

Commit 432be8f

Browse files
authored
Merge pull request #24 from Hi-Angel/dont-highlight-toplevel-only-keywords
Don't highlight top-level-only keywords at different levels
2 parents d187b3d + 0a8aebb commit 432be8f

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

purescript-font-lock.el

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,16 +172,22 @@ Returns keywords suitable for `font-lock-keywords'."
172172
;; "@" "~" "=>") t)
173173
"\\(->\\|\\.\\.\\|::\\|∷\\|<-\\|=>\\|[=@\\|~]\\)"
174174
"\\S_"))
175+
;; These are only keywords when appear at top-level, optionally with
176+
;; indentation. They are not reserved and in other levels would represent
177+
;; record fields or other identifiers.
178+
(toplevel-keywords
179+
(rx line-start (zero-or-more whitespace)
180+
(group (or "type" "module" "import" "data" "class" "newtype"
181+
"instance" "derive")
182+
word-end)))
175183
;; Reserved identifiers
176184
(reservedid
177185
;; `as', `hiding', and `qualified' are part of the import
178186
;; spec syntax, but they are not reserved.
179187
;; `_' can go in here since it has temporary word syntax.
180188
(regexp-opt
181-
'("ado" "case" "class" "data" "default" "deriving"
182-
"do" "else" "if" "import" "in" "infix" "infixl"
183-
"infixr" "instance" "let" "module" "newtype" "of"
184-
"then" "type" "where" "_") 'words))
189+
'("ado" "case" "default" "do" "else" "if" "in" "infix"
190+
"infixl" "infixr" "let" "of" "then" "where" "_") 'words))
185191

186192
;; Top-level declarations
187193
(topdecl-var
@@ -210,6 +216,7 @@ Returns keywords suitable for `font-lock-keywords'."
210216
("^>>>>>>> .*$" 0 'font-lock-warning-face t)
211217
("^#.*$" 0 'font-lock-preprocessor-face t)
212218

219+
(,toplevel-keywords 1 (symbol-value 'purescript-keyword-face))
213220
(,reservedid 1 (symbol-value 'purescript-keyword-face))
214221
(,reservedsym 1 (symbol-value 'purescript-operator-face))
215222
;; Special case for `as', `hiding', `safe' and `qualified', which are

0 commit comments

Comments
 (0)