summaryrefslogtreecommitdiff
path: root/.config/emacs/modules
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2024-11-01 16:55:51 +0100
committerThomas Voss <mail@thomasvoss.com> 2024-11-01 16:55:51 +0100
commitc5b4c7a028f2bf15d99753efc6f43b6e0b8d9e5e (patch)
tree26c27a16711fc3829fe10acf83b099b977ab94b9 /.config/emacs/modules
parentc34d8a4615f6c60b2ea216bcdd51d3984fb7ce93 (diff)
emacs: Highlight ‘__func__’ and ‘__FUNCTION__’ in C
Diffstat (limited to '.config/emacs/modules')
-rw-r--r--.config/emacs/modules/mm-treesit.el20
1 files changed, 19 insertions, 1 deletions
diff --git a/.config/emacs/modules/mm-treesit.el b/.config/emacs/modules/mm-treesit.el
index 75e679f..ed8a299 100644
--- a/.config/emacs/modules/mm-treesit.el
+++ b/.config/emacs/modules/mm-treesit.el
@@ -137,4 +137,22 @@ This alist is used to configure `auto-mode-alist'.")
;; https://github.com/tree-sitter/tree-sitter-c/issues/236
(append keywords '("constexpr"))))
-(provide 'mm-treesit)
+
+;;; Highlight Predefined Variables
+
+(with-eval-after-load 'treesit
+ (defvar mm-c-font-lock-rules
+ (treesit-font-lock-rules
+ :language 'c
+ :feature 'constant
+ :override t
+ `(((identifier) @font-lock-constant-face
+ (:match ,(rx bos (or "__func__" "__FUNCTION__") eos)
+ @font-lock-constant-face))))))
+
+(add-hook 'c-ts-mode-hook
+ (defun mm-c-apply-font-lock-extras ()
+ (setq treesit-font-lock-settings
+ (append treesit-font-lock-settings mm-c-font-lock-rules))))
+
+(provide 'mm-treesit) \ No newline at end of file