From: Randy Taylor <dev@rjt.dev>
To: Yuan Fu <casouri@gmail.com>
Cc: acidbong@tilde.club, Trevor Arjeski <tmarjeski@gmail.com>,
74277@debbugs.gnu.org, Eli Zaretskii <eliz@gnu.org>
Subject: bug#74277: 29.4; rust-ts-mode doesn't highlight some function calls
Date: Sat, 14 Dec 2024 19:25:13 +0000 [thread overview]
Message-ID: <jGzD96C0bfqddBstdkJBN51on7MKKo4BSkZza8AHf_WBPhcZlxAVYweGjbUix6IhFLomBGC2808XaEBFPQak1zZZ-Ne5MIMnWVV1hx5p0E8=@rjt.dev> (raw)
In-Reply-To: <A7125ACD-63F3-4381-9135-DE099A661F74@gmail.com>
On Sunday, November 24th, 2024 at 00:18, Yuan Fu <casouri@gmail.com> wrote:
>
>
> > On Nov 21, 2024, at 7:30 PM, Randy Taylor dev@rjt.dev wrote:
> >
> > On Wednesday, November 20th, 2024 at 13:22, Trevor Arjeski tmarjeski@gmail.com wrote:
> >
> > > Trevor Arjeski tmarjeski@gmail.com writes:
> > >
> > > I decided to hack around with this a little bit and found that adding
> > > the following lines partially works:
> > >
> > > I'm sure there is an issue with solving it this way, I just need someone
> > > else more experienced to confirm. It is finicky where it turns the
> > > highlighting on and off when you make some code changes, for example
> > > adding and removing the semi-colon after the macro invocation.
> >
> > Yuan would be the best to answer that.
>
>
> Using injection (what Emacs calls local parser, same thing) here is fine, I think. As Randy said, tree-sitter doesn’t have a good answer for macros. If nvim uses this workaround (create an injection for the macro and parses it like normal rust code), then it should be fine for us to follow suit.
>
> > Personally, I envisioned a custom highlight helper function like
> > rust-ts-mode--fontify-pattern or rust-ts-mode--fontify-scope which
> > seems like the simplest solution that should cover this use case, but
> > I'm not actually aware of all the sorts of craziness one could get up
> > to in a macro invocation so that might not be enough and maybe injections
> > are the way to go.
>
>
> Rust macros are not as crazy as C/C++, but definitely goes beyond normal rust code, for example, the select! macro:
>
> #[tokio::main]
> async fn main() {
> tokio::select! {
> _ = do_stuff_async() => {
>
> println!("do_stuff_async() completed first")
> }
> _ = more_async_work() => {
>
> println!("more_async_work() completed first")
> }
> };
> }
>
> Does what you envisioned work for something like this? To be fair, I don’t think the injection solution works well for this either.
>
> Yuan
Sorry for the super late reply!
The custom highlighter function(s) would definitely not be the best way for macros like that. Back when this was discussed ages ago, I remember that injection had some problems or questions surrounding it (don't remember the details), so depending on whether those can be ironed out (whatever those issues were if they even still apply), we may only be able to tackle simpler highlights with those custom highlighter functions until injection becomes more feasible.
But injection seems to be the way to go to cover all types of macros appropriately.
prev parent reply other threads:[~2024-12-14 19:25 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-08 20:24 bug#74277: 29.4; rust-ts-mode doesn't highlight some function calls acidbong--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-09 8:52 ` Eli Zaretskii
2024-11-10 21:10 ` Randy Taylor
2024-11-19 20:48 ` Trevor Arjeski
2024-11-20 12:34 ` Acid Bong via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-20 18:22 ` Trevor Arjeski
2024-11-22 3:30 ` Randy Taylor
2024-11-24 5:18 ` Yuan Fu
2024-11-24 7:17 ` Trevor Arjeski
2024-11-25 7:34 ` Yuan Fu
2024-12-14 19:25 ` Randy Taylor [this message]
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='jGzD96C0bfqddBstdkJBN51on7MKKo4BSkZza8AHf_WBPhcZlxAVYweGjbUix6IhFLomBGC2808XaEBFPQak1zZZ-Ne5MIMnWVV1hx5p0E8=@rjt.dev' \
--to=dev@rjt.dev \
--cc=74277@debbugs.gnu.org \
--cc=acidbong@tilde.club \
--cc=casouri@gmail.com \
--cc=eliz@gnu.org \
--cc=tmarjeski@gmail.com \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.