Skip to content
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

Don't highlight top-level-only keywords at different levels #24

Merged
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
15 changes: 11 additions & 4 deletions purescript-font-lock.el
Original file line number Diff line number Diff line change
Expand Up @@ -172,16 +172,22 @@ Returns keywords suitable for `font-lock-keywords'."
;; "@" "~" "=>") t)
"\\(->\\|\\.\\.\\|::\\|∷\\|<-\\|=>\\|[=@\\|~]\\)"
"\\S_"))
;; These are only keywords when appear at top-level, optionally with
;; indentation. They are not reserved and in other levels would represent
;; record fields or other identifiers.
(toplevel-keywords
(rx line-start (zero-or-more whitespace)
(group (or "type" "module" "import" "data" "class" "newtype"
"instance" "derive")
word-end)))
;; Reserved identifiers
(reservedid
;; `as', `hiding', and `qualified' are part of the import
;; spec syntax, but they are not reserved.
;; `_' can go in here since it has temporary word syntax.
(regexp-opt
'("ado" "case" "class" "data" "default" "deriving"
"do" "else" "if" "import" "in" "infix" "infixl"
"infixr" "instance" "let" "module" "newtype" "of"
"then" "type" "where" "_") 'words))
'("ado" "case" "default" "do" "else" "if" "in" "infix"
"infixl" "infixr" "let" "of" "then" "where" "_") 'words))

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

(,toplevel-keywords 1 (symbol-value 'purescript-keyword-face))
(,reservedid 1 (symbol-value 'purescript-keyword-face))
(,reservedsym 1 (symbol-value 'purescript-operator-face))
;; Special case for `as', `hiding', `safe' and `qualified', which are
Expand Down
Loading