("^\\s-*\\(.+?\\)\\(?:\\[\\(.*?\\)\\]\\)?\\s-*="
(1 'font-lock-variable-name-face)
(2 'font-lock-constant-face nil t))
+ ;; Must be lower-case according to the TOML spec.
("\\_<false\\|true\\_>" 0 'font-lock-keyword-face))
"Keywords to highlight in Conf TOML mode.")
\[entry]
value = \"some string\""
- (conf-mode-initialize "#" 'conf-toml-font-lock-keywords)
+ (conf-mode-initialize "#")
+ ;; Booleans are "always lowercase", so we must *not* use case
+ ;; folding. Therefore, we can't set it using `conf-mode-initialize´.
+ (setq-local font-lock-defaults `(,conf-toml-font-lock-keywords nil nil nil nil))
(setq-local conf-assignment-column 0)
(setq-local conf-assignment-sign ?=))
(should-not (face-at-point))))
(ert-deftest conf-test-toml-mode ()
- ;; From `conf-toml-mode' docstring.
(with-temp-buffer
(insert "[entry]
value = \"some string\"")
(search-forward "som")
(should (equal (face-at-point) 'font-lock-string-face))))
+(ert-deftest conf-test-toml-mode/boolean ()
+ ;; https://toml.io/en/v1.0.0#boolean
+ (with-temp-buffer
+ (insert "[entry]
+a = true
+b = True")
+ (goto-char (point-min))
+ (conf-toml-mode)
+ (font-lock-mode)
+ (font-lock-ensure)
+ (search-forward "tru")
+ (should (equal (face-at-point) 'font-lock-keyword-face))
+ ;; Do not fontify upper-case "True".
+ (search-forward "Tru")
+ (should (equal (face-at-point) nil))))
+
(ert-deftest conf-test-desktop-mode ()
;; From `conf-desktop-mode' dostring.
(with-temp-buffer