[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Tree sitter support for C-like languages
From: |
Yuan Fu |
Subject: |
Re: Tree sitter support for C-like languages |
Date: |
Tue, 15 Nov 2022 23:58:57 -0800 |
> On Nov 15, 2022, at 10:38 AM, Eli Zaretskii <eliz@gnu.org> wrote:
>
>> From: Yuan Fu <casouri@gmail.com>
>> Date: Tue, 15 Nov 2022 10:18:21 -0800
>> Cc: Stefan Monnier <monnier@iro.umontreal.ca>,
>> theo@thornhill.no,
>> emacs-devel@gnu.org
>>
>>> Maybe we should grow some augmentations for tree-sitter, at least
>>> given enough time. Or maybe it's possible to identify the parts where
>>> this happens by some tree-sitter indications, and tweak the faces in
>>> those regions in some way.
>>
>> I don’t know how could you improve this in tree-sitter since macros are
>> literally “define you own syntax”. We can reasonably fix the highlighting
>> for some of our macros like DEFUN. As a demonstration I added some
>> emacs-devel-specific rules (that are disabled by default). Run this:
>>
>> (add-hook 'c-ts-mode-hook
>> (lambda ()
>> (treesit-font-lock-recompute-features '(emacs-devel))))
>>
>> And restart c-ts-mode, and DEFUN’s should look normal now.
>
> I will try that when I have time, thanks. But if this indeed works
> well, why not do something similar to fix more warnings?
Truth to be told, I don’t know how to fix errors around preprocessor directive
(#ifdef’s). Our macros shouldn’t be hard to fix. We can fix them as we
encounter them.
> And why not
> make this the default, instead of asking users to write mode hooks?
Because this is Emacs-specific? It specifically fixes highlight for the DEFUN
macro, nothing else. We can add some dir-local config that automatically
enables this.
Yuan
- Re: Tree sitter support for C-like languages, (continued)
- Re: Tree sitter support for C-like languages, Eli Zaretskii, 2022/11/14
- Re: Tree sitter support for C-like languages, Yuan Fu, 2022/11/14
- Re: Tree sitter support for C-like languages, Eli Zaretskii, 2022/11/14
- Re: Tree sitter support for C-like languages, Yuan Fu, 2022/11/15
- Re: Tree sitter support for C-like languages, Theodor Thornhill, 2022/11/15
- Re: Tree sitter support for C-like languages, Eli Zaretskii, 2022/11/15
- Re: Tree sitter support for C-like languages, Stefan Monnier, 2022/11/15
- Re: Tree sitter support for C-like languages, Eli Zaretskii, 2022/11/15
- Re: Tree sitter support for C-like languages, Yuan Fu, 2022/11/15
- Re: Tree sitter support for C-like languages, Eli Zaretskii, 2022/11/15
- Re: Tree sitter support for C-like languages,
Yuan Fu <=
- Re: Tree sitter support for C-like languages, Eli Zaretskii, 2022/11/16
- Re: Tree sitter support for C-like languages, Po Lu, 2022/11/16
- Re: Tree sitter support for C-like languages, Yuan Fu, 2022/11/16
- Re: Tree sitter support for C-like languages, Visuwesh, 2022/11/15
- Re: Tree sitter support for C-like languages, Yuan Fu, 2022/11/15
- Re: Tree sitter support for C-like languages, Stefan Monnier, 2022/11/14
- Re: Tree sitter support for C-like languages, Dmitry Gutov, 2022/11/14
- Re: Tree sitter support for C-like languages, Yuan Fu, 2022/11/14
- Re: Tree sitter support for C-like languages, Dmitry Gutov, 2022/11/14
- Re: Tree sitter support for C-like languages, Yuan Fu, 2022/11/15