-
-
Notifications
You must be signed in to change notification settings - Fork 228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lsp: formatting malformed when CSS expressions are too long #733
Comments
I got a similar issue here: Works:
Doesnt work
|
Did a bit more investigation on what would work and what not. Works
or Alternativly using comma to concatenate the strings works fine
Maybe allowing the first Token of the next not empty line to be one of the allowed concatinatino tokens would remove the issue |
Hey folks, thank you for the error report, your great minimal repros and your patience! Though, I'm having issues reproducing both with latest templ and v0.2.680, so I think we will have to gather some more data if you have time:
|
Thanks for the Update
I would say that its more of a default behavoir problem since most languages support the pattern below (which is the actual issue not the formatter itself)
|
Sorry, I think I phrased one of my questions poorly.
Is formatted to
By your editor, is that right? If you run My suspicion is that the html-lsp is breaking the formatting. |
There was a very similar issue here: #541 The solution was to configure nvim to only use templ to format templ files. You can use conform to do this:
|
Thanks for the reply, its indeed just my editor, thanks for the config.
i just wanted to say that the corrently broken code should be supported since its a common way code is formatted. Thank u for the help. |
I disagree that this should be valid syntax, though I may be wrong! Anything between those curly braces is Go code, and a line starting with a Valid Go code: func main() {
fmt.Println("Hello, " +
"world!")
} Invalid Go code. func main() {
fmt.Println("Hello, "
+ "world!")
} |
This resolved it for me, thanks! I'll leave this issue open until the discussion (and agreement, if this is a bug) with @JuLi0n21 is finished? |
If it's not supported by default in go then I'm in the wrong👍 |
Awesome, thanks for coming back to the issue folks! Will close it off. |
templ version v0.2.680
The following example templates works fine:
Now, if there is one more
foo
added to the list of classes, the LSP formatter seems to malform the template, resulting in the following output:This results in an error:
string expression attribute: missing closing brace: line 3, col 27 []
The text was updated successfully, but these errors were encountered: