GNU bug report logs -
#61655
[Tree sitter] [Feature Request] font-lock function calls, definitions, separately
Previous Next
Full log
View this message in rfc822 format
Jacob Faibussowitsch <jacob.fai <at> gmail.com> writes:
> Hello,
>
> Is it possible to have the builtin tree sitter give differentiate font-locking for function calls and function definitions?
>
> The 3rd party tree-sitter package (https://github.com/emacs-tree-sitter/elisp-tree-sitter) has this feature and it is quite
> nice. In fact it goes further, allowing you to additionally distinguish between builtin calls, macro calls, method calls, etc.
> (see https://github.com/emacs-tree-sitter/elisp-tree-sitter/blob/master/lisp/tree-sitter-hl.el).
>
> As far as I could see, the builtin mode only provides `font-lock-function-name-face`. I have set treesit-font-lock-level to
> 4.
>
> Examples below are for C/C++ mode, but this would apply to any number of languages.
>
> Desired (i.e. what 3rd party package produces):
>
> *
>
> Current:
>
> *
Hmmm, yeah. The builtin tree-sitter maps syntax queries directly into
faces, where the third-party tree-sitter maps syntax queries to some
syntax types, then maps types to faces. So it would be a bit harder to
do fine-grained control like in the builtin tree-sitter, comparing to
the third-party one.
I’ve thought of this idea before but didn’t pursue it further: Right now
we allow capture names to be face names and functions, eg
(commment) @font-lock-comment-face
or
(comment) @xxx-moode-fortify-comment
Maybe we can add a third type, arbitrary symbols, like
(comment) @comment
and add a variables treesit-font-lock-mapping which maps symbols to
faces or functions:
((comment . font-lock-comment-face))
or
((comment . xxx-mode-fontify-comment))
Then we can easily support differentiating between function call and
function definition.
Yuan
This bug report was last modified 2 years and 88 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.