From: Yuan Fu <casouri@gmail.com>
To: Theodor Thornhill <theo@thornhill.no>
Cc: emacs-devel <emacs-devel@gnu.org>
Subject: Re: Comments to the new tree sitter implementation
Date: Mon, 25 Apr 2022 15:46:43 -0700 [thread overview]
Message-ID: <A700EEF7-0911-483E-89F1-8727711BDAC5@gmail.com> (raw)
In-Reply-To: <87v8uxx9oj.fsf@thornhill.no>
>
> Hi, there!
>
>>
>> Sorry that I can’t get back to you very soon. I’ve been incredibly
>> busy recently. I’ll find time to look at your points and try to debug
>> the problems you mention with typescript-ts.el.
>>
>
> No worries. I'll just note one more thing because I remember it now:
> Why are you calling the font lock default function after tree sitter has
> done its job? That seems like the wrong thing for several reasons:
>
> 1. Shouldn't tree sitter be sufficient?
> 2. It makes the default function get higher precedence than tree-sitter,
> causing some troublesome behavior.
That is intended. Maybe I should emphasize in the manual that major modes shouldn’t set regex font-locks if tree-sitter is enabled (added to todo list). I left regex font-lock enabled and to have higher precedence because many Emacs features uses regex font-lock for arbitrary highlighting. One example is highlight-regexp, but also highlights for outline, and packages like hl-todo, rainbow-mode, etc. It makes sense for their highlights to override the “base” highlight applied by tree-sitter.
>
> Specifically, if you set single-quote as a string in the syntax table,
> to make the major mode understand it as a string delimiter, it will mess
> up comments. This example snippet will make the rest of the file
> fontlock as a string:
>
> ```typescript
> function foo() {
> // don't mark the rest of the file as a string because of this:
> // ^
> const dont = 3;
> const do = "":
> const it = {};
> }
> ```
>
> If the last two lines of `tree-sitter-font-lock-fontify-region` are
> removed, things appear to work as normal. It also works fine with
> things such as eglot marking a variable as unused in the comment face
> etc.
IIUC this can be solved by disabling the syntax-table-based font-locking by setting KEYWORDS-ONLY in font-lock-defaults.
Thanks,
Yuan
next prev parent reply other threads:[~2022-04-25 22:46 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-23 12:33 Comments to the new tree sitter implementation Theodor Thornhill
2022-04-23 22:27 ` Stefan Monnier
2022-04-24 5:06 ` Theodor Thornhill
2022-04-24 5:36 ` Theodor Thornhill
2022-04-24 20:27 ` Stefan Monnier
2022-04-25 18:52 ` Yuan Fu
2022-04-25 19:07 ` Eli Zaretskii
2022-05-07 6:49 ` Yuan Fu
2022-05-07 7:11 ` Eli Zaretskii
2022-05-07 7:17 ` Yuan Fu
2022-04-25 19:08 ` Theodor Thornhill
2022-04-25 22:46 ` Yuan Fu [this message]
2022-04-26 6:38 ` Theodor Thornhill
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=A700EEF7-0911-483E-89F1-8727711BDAC5@gmail.com \
--to=casouri@gmail.com \
--cc=emacs-devel@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 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.