branch: elpa/nix-mode
commit 3e6fdd8311104e9a8ae77ae82437071392c4c86a
Author: Matthew Bauer <[email protected]>
Commit: Matthew Bauer <[email protected]>
Add back syntax coloring of antiquotes.
Fixes issue #20.
---
nix-mode.el | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)
diff --git a/nix-mode.el b/nix-mode.el
index 2fa86c44b2..a9b8337297 100644
--- a/nix-mode.el
+++ b/nix-mode.el
@@ -26,6 +26,25 @@
;;; Syntax coloring
+(defun nix-syntax-match-antiquote (limit)
+ "Find antiquote within a Nix expression up to LIMIT."
+ (let ((pos (next-single-char-property-change (point) 'nix-syntax-antiquote
+ nil limit)))
+ (when (and pos (> pos (point)) (< pos (point-max)))
+ (goto-char pos)
+ (let ((char (char-after pos)))
+ (pcase char
+ (`?{
+ (forward-char 1)
+ (set-match-data (list (1- pos) (point)))
+ t)
+ (`?}
+ (forward-char 1)
+ (set-match-data (list pos (point)))
+ t))
+ )
+ )))
+
(defconst nix-keywords
'("if" "then"
"else" "with"
@@ -65,7 +84,9 @@
(,nix-re-url . font-lock-constant-face)
(,nix-re-file-path . font-lock-constant-face)
(,nix-re-variable-assign 1 font-lock-variable-name-face)
- (,nix-re-bracket-path . font-lock-constant-face))
+ (,nix-re-bracket-path . font-lock-constant-face)
+ (nix-syntax-match-antiquote 0 font-lock-preprocessor-face t)
+ )
"Font lock keywords for nix.")
(makunbound 'nix-mode-syntax-table)