Skip to content

Commit aa1fa07

Browse files
committedJun 26, 2019
Fix handling of keywords in identifiers
This case shouldn’t be highlighted. For instance: python-with-my-packages Need to look ahead and behind keywords to make sure they are not used in attribute names.
1 parent 2f4bd0f commit aa1fa07

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed
 

‎nix-mode.el

+12-3
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,19 @@ very large Nix files (all-packages.nix)."
128128

129129
(defconst nix-re-comments "#\\|/*\\|*/")
130130

131+
(defun nix-re-keywords (keywords)
132+
"Produce a regexp matching some keywords of Nix.
133+
KEYWORDS a list of strings to match as Nix keywords."
134+
(concat
135+
"\\(?:[[:space:]]\\|^\\)"
136+
(regexp-opt keywords t)
137+
"\\(?:[[:space:]]\\|$\\)"
138+
))
139+
131140
(defconst nix-font-lock-keywords
132-
`((,(regexp-opt nix-keywords 'symbols) 0 'nix-keyword-face)
133-
(,(regexp-opt nix-warning-keywords 'symbols) 0 'nix-keyword-warning-face)
134-
(,(regexp-opt nix-builtins 'symbols) 0 'nix-builtin-face)
141+
`((,(nix-re-keywords nix-keywords) 1 'nix-keyword-face)
142+
(,(nix-re-keywords nix-warning-keywords) 1 'nix-keyword-warning-face)
143+
(,(nix-re-keywords nix-builtins) 1 'nix-builtin-face)
135144
(,nix-re-url 0 'nix-constant-face)
136145
(,nix-re-file-path 0 'nix-constant-face)
137146
(,nix-re-variable-assign 1 'nix-attribute-face)

0 commit comments

Comments
 (0)
Please sign in to comment.