vrischmann / tree-sitter-templ

MIT License
77 stars 21 forks source link

indents support #27

Closed AnthonyPoschen closed 3 weeks ago

AnthonyPoschen commented 9 months ago

Hi, i have been on a bit of a mission getting templ the way i like downstream.

https://github.com/windwp/nvim-ts-autotag/pull/154 https://github.com/windwp/nvim-ts-autotag/pull/155

which has now lead me upstream to needing the default indenting in templ to be correct for my OCD of feature completeness.

https://github.com/vrischmann/tree-sitter-templ/assets/2253299/765df34a-e70c-4af0-9861-ec42899d3784

I have only just looked into treesitter and its syntax stuff now, is their any plans on indent support soonish and if not, how could i figure out how to contribute such a feature.

vrischmann commented 9 months ago

Hi.

I don't have any specific plans to add indent support because I don't need it, but I could look into it someday.

As far as I understand to add indent support you would need to add a indents.scm query file to nvim-treesitter, like there is for Go. And then enable indent support.

So I don't think there's anything to do with the parser.

vrischmann commented 9 months ago

I gave it a try for about 2 hours (see here, copied/adapted the queries from HTML) but it doesn't work and I don't understand why.

I'll probably come back to this when the feature is less experimental.

AnthonyPoschen commented 9 months ago

i also did give it a try last night, but wasn't sure if i had everything setup correctly or it just didn't work. I will look at that and see what i can do

AnthonyPoschen commented 9 months ago

so i placed what you supplied inside my ~/.config/nvim/after/queries/templ/indents.scm and it worked right out of the box!

AnthonyPoschen commented 9 months ago

its got a bit of qwerks to it, but its mostly working as intended.

https://github.com/vrischmann/tree-sitter-templ/assets/2253299/956ccf0a-229e-49a4-8506-77146546a7ec

vrischmann commented 9 months ago

thanks for testing. It's weird that it doesn't work for me.

vrischmann commented 5 months ago

Hi @AnthonyPoschen. is this still a problem for you or can I close this issue ?

AnthonyPoschen commented 5 months ago

It's the evening on Sunday here. Haven't been using it lately so can't recall. I'll check tomorrow after work and report back.

On Sun, May 12, 2024, 5:20 PM Vincent Rischmann @.***> wrote:

Hi @AnthonyPoschen https://github.com/AnthonyPoschen. is this still a problem for you or can I close this issue ?

— Reply to this email directly, view it on GitHub https://github.com/vrischmann/tree-sitter-templ/issues/27#issuecomment-2106148417, or unsubscribe https://github.com/notifications/unsubscribe-auth/AARGD44A72GVUBE4KGYRBELZB4J35AVCNFSM6AAAAABCD4UTRWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMBWGE2DQNBRG4 . You are receiving this because you were mentioned.Message ID: @.***>