Skip to content

Commit 0f7b4ad

Browse files
authored
Merge pull request #50 from Hi-Angel/font-lock-operator-improvements
Operator highlight extended and improved
2 parents 6eb17d9 + 1a0e939 commit 0f7b4ad

File tree

2 files changed

+99
-80
lines changed

2 files changed

+99
-80
lines changed

purescript-font-lock.el

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@
128128
;; This is probably just wrong, but it used to use
129129
;; `font-lock-function-name-face' with a result that was not consistent with
130130
;; other major modes, so I just exchanged with `purescript-definition-face'.
131-
(defvar purescript-operator-face 'font-lock-variable-name-face)
131+
(defvar purescript-operator-face 'font-lock-builtin-face)
132132
(defvar purescript-default-face nil)
133133
(defvar purescript-literate-comment-face 'font-lock-doc-face
134134
"Face with which to fontify literate comments.
@@ -165,12 +165,10 @@ Returns keywords suitable for `font-lock-keywords'."
165165
;; be thrown for some reason by backslash's escape syntax.
166166
"\\(\\s_\\|\\\\\\)+")
167167

168-
;; Reserved operations
169-
(reservedsym
168+
(operator
170169
(concat "\\S_"
171-
;; (regexp-opt '(".." "::" "=" "\\" "|" "<-" "->"
172-
;; "@" "~" "=>") t)
173-
"\\(->\\|\\.\\.\\|::\\|∷\\|<-\\|=>\\|[=@\\|~]\\)"
170+
;; All punctuation, excluding (),;[]{}_"'`
171+
"\\([!@#$%^&*+\\-./<=>?@|~:∷\\\\]+\\)"
174172
"\\S_"))
175173
;; These are only keywords when appear at top-level, optionally with
176174
;; indentation. They are not reserved and in other levels would represent
@@ -210,7 +208,7 @@ Returns keywords suitable for `font-lock-keywords'."
210208
;;
211209
(,toplevel-keywords 1 (symbol-value 'purescript-keyword-face))
212210
(,reservedid 1 (symbol-value 'purescript-keyword-face))
213-
(,reservedsym 1 (symbol-value 'purescript-operator-face))
211+
(,operator 1 (symbol-value 'purescript-operator-face))
214212
;; Special case for `as', `hiding', `safe' and `qualified', which are
215213
;; keywords in import statements but are not otherwise reserved.
216214
("\\<import[ \t]+\\(?:\\(safe\\>\\)[ \t]*\\)?\\(?:\\(qualified\\>\\)[ \t]*\\)?[^ \t\n()]+[ \t]*\\(?:\\(\\<as\\>\\)[ \t]*[^ \t\n()]+[ \t]*\\)?\\(\\<hiding\\>\\)?"
@@ -232,13 +230,12 @@ Returns keywords suitable for `font-lock-keywords'."
232230
(,topdecl-sym (2 (symbol-value 'purescript-definition-face)))
233231
(,topdecl-sym2 (1 (symbol-value 'purescript-definition-face)))
234232

235-
;; These four are debatable...
236-
("(\\(,*\\|->\\))" 0 (symbol-value 'purescript-constructor-face))
233+
;; This one is debatable…
237234
("\\[\\]" 0 (symbol-value 'purescript-constructor-face))
238235
;; Expensive.
239236
(,qvarid 0 (symbol-value 'purescript-default-face))
240237
(,qconid 0 (symbol-value 'purescript-constructor-face))
241-
(,(concat "\`" varid "\`") 0 (symbol-value 'purescript-operator-face))
238+
(,(concat "`" varid "`") 0 (symbol-value 'purescript-operator-face))
242239
;; Expensive.
243240
(,conid 0 (symbol-value 'purescript-constructor-face))
244241

0 commit comments

Comments
 (0)