tree-sitter-templ
tree-sitter-templ copied to clipboard
Syntax highlighting boke after using a component which has a child with NVIM.
Hi!
With the latest version of this project, my syntax highlighting is failing when I using a component with another one inside. I seen a similar closed issue which one is should be fix this, but that fix is not working for me.
For test environment, I used the recommended minimal NVIM configuration from the templ guide.
The current version of this project highlight my code like this:
If I remove the @ character, the highlighting works again like this:
Hi,
a quick test show we don't handle import expressions using the form
@Foo{
}
right the now parser thinks the {
starts a new block and it breaks parsing.
Can you share the code of components.FieldControl
and components.Select
to make it easier for me to debug ?
Of course, here you go:
package components
type Select struct {
Values []SelectValues
Class string
Selected string
Placeholder string
Attrs templ.Attributes
}
type SelectValues struct {
Value string
Data string
}
templ (i Select) Select() {
<div class="select is-fullwidth">
<select { i.Attrs... }>
for k, v := range i.Values {
if k == 0 && i.Placeholder != "" {
<option selected?={ i.Selected=="" } disabled value="">{ i.Placeholder }</option>
}
<option selected?={ v.Value==i.Selected } value={ v.Value }>{ v.Data }</option>
}
</select>
</div>
}
package components
templ FieldControl(label string) {
<div class="field">
<label class="label">{ label }</label>
<div class="control">
{ children... }
</div>
</div>
}
Hi,
a quick test show we don't handle import expressions using the form
@Foo{ }
right the now parser thinks the
{
starts a new block and it breaks parsing.Can you share the code of
components.FieldControl
andcomponents.Select
to make it easier for me to debug ?
Stumbled on this:
right the now parser thinks the
{
starts a new block and it breaks parsing.
Is there any news?
I'm trying something similar, but with inconsistencies.
Edit:
Could you point me on the files that would need to be modified to extend the parser? I've never touched tree-sitter stuff, got some tiny c + compiler/parser experience, maybe I could give a hand
Hi, I started working on this a while ago in this branch: https://github.com/vrischmann/tree-sitter-templ/tree/fix-import-expression-brace but IIRC it doesn't work and I didn't touch it since then.
I don't have time right now to work on this, if you want to work on this feel free to base your work on my branch.
Okay, will look into it when I have the chance :)
Thank you