Skip to content

Commit

Permalink
feat(fontlock): add highlighting of null keyword
Browse files Browse the repository at this point in the history
  • Loading branch information
Fuco1 committed Nov 16, 2023
1 parent 25a22a6 commit e8b57df
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions terraform-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@
"Face for varriables."
:group 'terraform-mode)

(defconst terraform--constants-regexp
(concat "\\(?:^\\|[^.]\\)" (regexp-opt '("null") 'words)))

(defconst terraform--block-builtins-without-name-or-type-regexp
(rx line-start
(zero-or-more space)
Expand Down Expand Up @@ -154,6 +157,7 @@
(1 'terraform-builtin-face)
(2 'terraform-resource-type-face t)
(3 'terraform-resource-name-face t))
(,terraform--constants-regexp 1 'font-lock-constant-face)
,@hcl-font-lock-keywords))

(defun terraform-format-buffer ()
Expand Down
8 changes: 8 additions & 0 deletions test/test-highlighting.el
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@
keyword
(should (face-at-cursor-p 'font-lock-constant-face)))))

(ert-deftest font-lock--constants-keywords ()
"Syntax highlight of constant keywords"

(dolist (keyword '("null"))
(with-terraform-temp-buffer
keyword
(should (face-at-cursor-p 'font-lock-constant-face)))))

(ert-deftest font-lock--provider-block--with-one-space ()
"Syntax highlight of `provider' block."

Expand Down

0 comments on commit e8b57df

Please sign in to comment.