vrischmann / tree-sitter-templ

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Commenting not working; "commentstring empty"

eschmar opened this issue · comments

Hi, I'm facing some obstacles in my quest for templ support in nvim. It all seems to be working - except for commenting:

Screenshot 2024-02-13 at 09 29 03

Browsing through the issues here, it seems that commenting is working for others, which is why i'm posting here.

  • checkhealth: - templ ✓ . . . ✓
  • LspInfo: Both templ and html loaded.

I have tried creating .config/nvim/after/ftplugin/templ.lua with vim.bo.commentstring = "// %s". That would allow me to comment, but as soon as i save the file and auto-format does its thing, sections with comments break the file.

My setup is:

Trying a fresh lazyvim install with just enabling go+templ yielded the same result.. Is this working for others? Any advice would be highly appreciated! Sorry if I'm writing in the wrong place, I'm fairly new to more custom nvim configurations. Thanks!

Hi.

What do you mean by "commenting" exactly ? tree-sitter doesn't provide anything regarding commenting so I don't understand.

Sorry for the ambiguity and thanks for your response! With commenting I mean toggling a selection of code or a code line to be commented or un-commented (with gc). From the notes of mini.comment:

To use tree-sitter aware commenting, global value of 'commentstring' should be '' (empty string). This is the default value in Neovim>=0.9, so make sure to not set it manually.

I inferred from this excerpt that tree-sitter would provide instructions on how to comment. But now after your comment and reading into the source, that's not the case (it's from the file type).. I'll post a solution here if i can find one to at least provide some value to the issue, otherwise this can be closed. Thanks again!

Yeah skimming through the source code of mini.comment I don't quite get what tree-sitter should provide for it to work.