diff --git a/modules/ui/hl-todo/autoload.el b/modules/ui/hl-todo/autoload.el new file mode 100644 index 000000000..7aaa8b3bb --- /dev/null +++ b/modules/ui/hl-todo/autoload.el @@ -0,0 +1,14 @@ +;;; ui/hl-todo/autoload.el -*- lexical-binding: t; -*- + +;;;###autoload +(defun +hl-todo|use-face-detection () + "Use a different, more primitive method of locating todo keywords. + +This is useful for major modes that don't use or have a valid syntax-table entry +for comment start/end characters." + (set (make-local-variable 'hl-todo-keywords) + `(((lambda (limit) + (let (case-fold-search) + (and (re-search-forward hl-todo-regexp limit t) + (memq 'font-lock-comment-face (doom-enlist (get-text-property (point) 'face))))) + (1 (hl-todo-get-face) t t)))))) diff --git a/modules/ui/hl-todo/config.el b/modules/ui/hl-todo/config.el index 49521b7eb..8321cfc90 100644 --- a/modules/ui/hl-todo/config.el +++ b/modules/ui/hl-todo/config.el @@ -7,4 +7,10 @@ (setq hl-todo-keyword-faces `(("TODO" . ,(face-foreground 'warning)) ("FIXME" . ,(face-foreground 'error)) - ("NOTE" . ,(face-foreground 'success))))) + ("NOTE" . ,(face-foreground 'success)))) + + ;; Use a more primitive todo-keyword detection method in major modes that + ;; don't use/have a valid syntax table entry for comments. + (add-hook! + (pug-mode haml-mode) + #'+hl-todo|use-face-detection))