From: Jacob Faibussowitsch <jacob.fai@gmail.com>
To: Theodor Thornhill <theo@thornhill.no>
Cc: 61655@debbugs.gnu.org, Eli Zaretskii <eliz@gnu.org>,
Yuan Fu <casouri@gmail.com>
Subject: bug#61655: [Tree sitter] [Feature Request] font-lock function calls, definitions, separately
Date: Mon, 20 Feb 2023 15:45:37 -0500 [thread overview]
Message-ID: <50A8431B-EAD8-442B-9412-0C3649D8852F@gmail.com> (raw)
In-Reply-To: <871qmk9jaz.fsf@thornhill.no>
Hello All,
> Jacob, do you have any examples where it is wrong and what you expect instead?
I had attached some screen grabs in my initial email, if they don’t show up on your end they do show up on the web archives: https://lists.gnu.org/archive/html/bug-gnu-emacs/2023-02/msg01638.html.
The key differences are:
1. `foo()` (i.e. a function definition) is light-blue.
2. `bar()`, and `baz()` (function calls) are dark blue.
3. The member function call `b.mem_func()` highlights the `mem_func()` part in red.
On the other hand, the builtin tree sitter mode font-locks them all using the same light-blue color. Indeed performing M-x describe-face over each separate part yields only `font-lock-function-name-face` for builtin, while 3rd party returns separate faces (which are available to customize) for each case.
I looked through `c-ts-mode.el` as an example and found `c-ts-mode--font-lock-settings`. Treesitter already identifies all of the above cases as different nodes in the AST (as evidenced in treesit-explor-mode) so it seems that adding another set of matchers (and appropriate faces, e.g. font-lock-function-call-face)
:language mode
:feature 'label
'((call_expression
function: (identifier) @font-lock-function-call-face))
Should do the trick no?
Best regards,
Jacob Faibussowitsch
(Jacob Fai - booss - oh - vitch)
> On Feb 20, 2023, at 15:24, Theodor Thornhill <theo@thornhill.no> wrote:
>
> Eli Zaretskii <eliz@gnu.org> writes:
>
>>> From: Jacob Faibussowitsch <jacob.fai@gmail.com>
>>> Date: Mon, 20 Feb 2023 10:54:42 -0500
>>>
>>> Is it possible to have the builtin tree sitter give differentiate font-locking for function calls and function definitions?
>>
>> AFAIU, it already does. Yuan and Theo, am I wrong?
>
> You're not wrong, but it depends on each implementation whether or not
> the definition gets a different color or not. Jacob, do you have any
> examples where it is wrong and what you expect instead?
>
> Theo
next prev parent reply other threads:[~2023-02-20 20:45 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-20 15:54 bug#61655: [Tree sitter] [Feature Request] font-lock function calls, definitions, separately Jacob Faibussowitsch
2023-02-20 17:03 ` Eli Zaretskii
2023-02-20 20:24 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-20 20:45 ` Jacob Faibussowitsch [this message]
2023-02-21 8:28 ` Yuan Fu
2023-02-21 9:55 ` Dmitry Gutov
2023-02-21 15:31 ` Jacob Faibussowitsch
2023-02-21 23:24 ` Dmitry Gutov
2023-02-22 18:07 ` Jacob Faibussowitsch
2023-02-22 21:39 ` Dmitry Gutov
2023-02-22 20:45 ` Yuan Fu
2023-02-22 21:38 ` Dmitry Gutov
2023-02-23 18:15 ` Eli Zaretskii
2023-02-24 2:31 ` Dmitry Gutov
2023-02-24 7:56 ` Eli Zaretskii
2023-02-24 11:31 ` Dmitry Gutov
2023-02-24 11:44 ` Eli Zaretskii
2023-02-24 14:24 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-25 1:06 ` Randy Taylor
2023-02-25 2:28 ` Dmitry Gutov
2023-02-25 3:59 ` Randy Taylor
2023-02-25 13:05 ` Dmitry Gutov
2023-02-28 2:09 ` Dmitry Gutov
2023-02-25 8:05 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=50A8431B-EAD8-442B-9412-0C3649D8852F@gmail.com \
--to=jacob.fai@gmail.com \
--cc=61655@debbugs.gnu.org \
--cc=casouri@gmail.com \
--cc=eliz@gnu.org \
--cc=theo@thornhill.no \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).