-
I only want tree-sitter to highlight c++ types, all the rest should be highlighted using emacs font-lock, i tried something like this but it everything other than types lose highlights (white/default) (add-function :before-while tree-sitter-hl-face-mapping-function
(lambda (face)
(unless (not (string= face "type")) face))) |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
IIRC emacs-tree-sitter de-activates font-lock on purpose and takes care of the highlighting. What's your reasoning for wanting to keep font-lock and emacs-tree-sitter co-existing? |
Beta Was this translation helpful? Give feedback.
-
@shackra having the best of both worlds, for instance tree-sitter screws up c++ macros (no highlighting at all), also there are some issues with operator overloads, namespace highlighting, but on of the solid things that tree-sitter does is highlighting types so i wanted to augment emac's font-lock with tree-sitter |
Beta Was this translation helpful? Give feedback.
-
If you want to use the coloring provided by (add-hook 'c++-mode-hook
(lambda ()
(setq-local tree-sitter-hl-use-font-lock-keywords t)
(add-function :before-while (local 'tree-sitter-hl-face-mapping-function)
(lambda (capture-name)
(string= capture-name "type"))))) |
Beta Was this translation helpful? Give feedback.
If you want to use the coloring provided by
font-lock-keywords
, you need to settree-sitter-hl-use-font-lock-keywords
as well, like this: