You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm currently trying to combine my HTML LSPs and Golang (gopls) LSP in HTML files, but I'm not having great success. The path I've taken so far is this:
First attempt
My first attempt was to just use HTML LSPs, but I unfortunately don't get syntax highlighting for any of the Go Template parts of the file, and if I use the vscode html LSP then it tries formatting my Go template sections, for example it thinks line 9 is real CSS, so it breaks up all the curly braces to format it as such.
The configuration for this attempt is:
My second attempt is to treat this as a gotmpl file, and then use tree sitter to inject the language as HTML for everything that's not a go template. Before the runtime injections the file looks like this (note, now the extension is .tmpl not .html as in the first attempt):
However once I set up these injections:
Now my file looks like this:
Syntax highlighting is all there, YAY! But it's not actually using my HTML LSPs on the HTML sections :(
For example, hover documentation isn't coming from the vscode LSP:
And tailwind isn't giving any suggestions on class lists:
It's as if it's just using the gopls lsp for these sections as well. (For example, the hover doc saying "constant" is the exact same behavior as without the injections).
I feel like I'm close, but I'm just missing how to get the HTML LSPs actually taking precedence on the HTML sections of the document.
Happy to provide any additional information that may be needed to figure out how to configure this.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm currently trying to combine my HTML LSPs and Golang (gopls) LSP in HTML files, but I'm not having great success. The path I've taken so far is this:
First attempt
My first attempt was to just use HTML LSPs, but I unfortunately don't get syntax highlighting for any of the Go Template parts of the file, and if I use the vscode html LSP then it tries formatting my Go template sections, for example it thinks line 9 is real CSS, so it breaks up all the curly braces to format it as such.

The configuration for this attempt is:
Second Attempt
My second attempt is to treat this as a gotmpl file, and then use tree sitter to inject the language as HTML for everything that's not a go template. Before the runtime injections the file looks like this (note, now the extension is

.tmpl
not.html
as in the first attempt):However once I set up these injections:
((text) @injection.content (#set! injection.language "html") (#set! injection.combined))
and my
languages.toml
to this:Now my file looks like this:



Syntax highlighting is all there, YAY! But it's not actually using my HTML LSPs on the HTML sections :(
For example, hover documentation isn't coming from the vscode LSP:
And tailwind isn't giving any suggestions on class lists:
It's as if it's just using the gopls lsp for these sections as well. (For example, the hover doc saying "constant" is the exact same behavior as without the injections).
I feel like I'm close, but I'm just missing how to get the HTML LSPs actually taking precedence on the HTML sections of the document.
Happy to provide any additional information that may be needed to figure out how to configure this.
Beta Was this translation helpful? Give feedback.
All reactions