From 03fd1922f97d5dddbf4e7fc018ebf2b90576f287 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jordi=20Guti=C3=A9rrez=20Hermoso?= Date: Tue, 10 Sep 2024 17:42:37 -0400 Subject: [PATCH] keywords: allow labels in block definitions According to the spec, after a type labels are allowed: https://developer.hashicorp.com/terraform/language/syntax/configuration#blocks This allows labels to be in the block definition after the type so that the type is still properly highlighted. --- hcl-mode.el | 2 +- test/test-highlighting.el | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/hcl-mode.el b/hcl-mode.el index 525a38c..069120d 100644 --- a/hcl-mode.el +++ b/hcl-mode.el @@ -53,7 +53,7 @@ (concat hcl--identifier-regexp "\\s-*=\\(?:[^>=]\\)")) (defconst hcl--map-regexp - (concat hcl--identifier-regexp "\\s-*{")) + (format "%1$s\\(?:\\s-*\"%1$s\"\\)*\\s-*{" hcl--identifier-regexp)) (defconst hcl--boolean-regexp (concat "\\(?:^\\|[^.]\\)" diff --git a/test/test-highlighting.el b/test/test-highlighting.el index 0510579..9c7ffed 100644 --- a/test/test-highlighting.el +++ b/test/test-highlighting.el @@ -75,6 +75,8 @@ output \"name\" { } } " + (forward-cursor-on "output") + (should (face-at-cursor-p 'font-lock-type-face)) (forward-cursor-on "bar") (should (face-at-cursor-p 'font-lock-variable-name-face))