[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: New cuda-ts-mode.
From: |
Philip Kaludercic |
Subject: |
Re: New cuda-ts-mode. |
Date: |
Wed, 29 Jan 2025 21:32:11 +0000 |
Ergus <spacibba@aol.com> writes:
> Hi:
>
> Yesterday I wrote an initial version of the cuda-ts-mode.
>
> Some months ago I was asking for a feature to simplify the
> implementation as Cuda tressitter is just the same C++ grammar with very
> little extensions (a few keywords and the <<< >>> brakets)
>
> My initial idea was to reuse all the c++-ts-mode and just add a couple
> of changes.
>
> This was actually quite hard for 3 reasons:
>
> 1. The treesit-language-remap-alist sometimes updated the grammar to
> cuda's but sometimes was still using the c++ one.
>
> 2. In c++-ts-mode--simple-indent-rules the conditions are limited to c
> and C++, so I needed to "hack" a bit to get the rules and set them in a
> cuda entry
>
> 3. There was no way to reuse the c-ts-mode--font-lock-settings function
> because of the :language entries + compilation. I needed to basically
> copy-paste the same code and remove the conditions (eq mode 'c++) to
> make it work.
> Also the function c-ts-mode--test-virtual-named-p hardcodes 'cpp
>
> I have a preliminar functional version that I would like to simplify and
> propose for to elpa.
>
> https://github.com/Ergus/cuda-ts-mode
I don't have any interesting comments, except that you swapped the body
and the docstring in `cuda-ts-mode--simple-indent-rules' and that you
are missing a footer (checkdoc hints to both of these problems).
> If we could modify c-ts-mode to reuse it's code, probably we could add
> Cuda (and maybe OpenCl) support to vanilla with VERY LITTLE code. I
> mean, I have now 250 lines o code for something that may be actually
> ~20-50.
What changes do you have in mind? If it is possible to extend the
built-in mode, then perhaps this should be done upstream to begin with,
instead of an external package?