tree-sitter-cmake icon indicating copy to clipboard operation
tree-sitter-cmake copied to clipboard

[feature] cmake comment

Open Freed-Wu opened this issue 8 months ago • 6 comments

#[=======================================================================[.rst:
The docs
#]=======================================================================]

Cmake comment can inject some other languages. Should we create a cmake-comment parser for it?

Freed-Wu avatar Apr 04 '25 06:04 Freed-Wu

This maybe is doable by modifying the scanner to emit more details about bracket comments (having something like open bracket, content, close bracket) and then queries can be written taking advantage of that. I'll try to do it when I have some time.

uyha avatar Apr 04 '25 07:04 uyha

This should be possible now with e51a18b037aad13676eb1a38ff1a6a207a3abbe7, you just need to write a query to inject the language. Let me know if you need any help.

uyha avatar Apr 07 '25 18:04 uyha

Can it be out-of-box in neovim's tree-sitter?

Freed-Wu avatar Apr 08 '25 05:04 Freed-Wu

It’s possible but I don’t think this is common enough to warrant adding it to nvim-treesitter. I haven’t seen this until you mention it. So I think it’s better if you add the injection to your own config. I can help you with that if you want.

uyha avatar Apr 08 '25 06:04 uyha

warrant adding it to nvim-treesitter

It depends maintainers of nvim-treesitter?

add the injection to your own config

A wiki should be welcome. :smile:

Freed-Wu avatar Apr 08 '25 08:04 Freed-Wu

It depends maintainers of nvim-treesitter?

Not really, the nvim-treesitter maintainers rely on the parser authors to make sense of the queries also, and I right now don't really see this use case being fitting enough.

A wiki should be welcome. 😄

The instruction is at https://github.com/nvim-treesitter/nvim-treesitter?tab=readme-ov-file#adding-queries but I can add a wiki page for this also.

uyha avatar Apr 08 '25 08:04 uyha