[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Implementing cuda-ts-mode
From: |
Yuan Fu |
Subject: |
Re: Implementing cuda-ts-mode |
Date: |
Thu, 25 Jul 2024 00:42:10 -0700 |
> On Jul 23, 2024, at 5:38 AM, Ergus <spacibba@aol.com> wrote:
>
> Hi:
>
> After a while and looking that the ts modules are getting mature I was
> planing to develop a `cuda-ts-mode'.
>
> However after reading the documentation it is not totally clear to me
> how to proceed in this specific case because cuda is a sort of
> "extension" over C++, so I expect that the cuda-ts-mode somehow
> "inherits" from c++-ts-mode.
>
> My initial idea was to replicate how I was expecting that c++-ts-mode
> should inherit from c-ts-mode, but it looks like this doesn't happen in
> a clear way. The modes are threated as independent and there is a sort
> of "mode" variable that is dynamically checked everywhere.
>
> So the simple question is:
>
> 1. The approach of trying to inherit from c++-ts-mode is correct? (I mean,
> is c++-ts-mode intended to be used like a "base" to inherit from?)
>
> Some advise on this?
IIUC, tree-sitter-cuda is a separate grammar that is extended from
tree-sitter-cpp, right? Then inheriting c++-ts-mode won’t work since it’ll
setup everything using the cpp grammar. You’d need to delete the cpp parser and
add your cuda parser (doable), and change everything that refers to ‘cpp to
‘cuda (very hacky).
I guess we can add some map which tells Emacs to use the cuda grammar in place
of cpp. Kind of like treesit-load-name-override-list but more dynamic.
Once we’re able to do that, you can define a new mode that derives from
c++-ts-mode and expect all the setup in c++-ts-mode to work.
Yuan