Skip to content
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

vscode: Bad highlighting when using generic functions #747

Closed
Jaimendo99 opened this issue May 20, 2024 · 3 comments · Fixed by templ-go/templ-vscode#58
Closed

vscode: Bad highlighting when using generic functions #747

Jaimendo99 opened this issue May 20, 2024 · 3 comments · Fixed by templ-go/templ-vscode#58
Labels
bug Something isn't working NeedsInvestigation Issue needs some investigation before being fixed vscode

Comments

@Jaimendo99
Copy link

I just wanted to create a table component that accepts different structs, but notice that the syntaxhighlighting got messed up after the generic declaration. here is a screenshot of the issue:
Screenshot from 2024-05-19 18-37-52
also the code:

type GenericInterface interface {
	Hello(name string) string
}

//Right Highlight
templ NoGenHello() {
	<p class="p-4 bg-slate-600 text-gray-300">
		Hello, no generic
	</p>
}
//Bad highlight
templ GenHello[T GenericInterface](obj T) {
	<p class="p-4 bg-slate-600 text-gray-300">
		{ obj.Hello("Templ") }
	</p>
}
@joerdav
Copy link
Collaborator

joerdav commented May 20, 2024

Hi, thanks for the report.

The LSP doesn't actually handle the syntax highlights, that's left to the editor plugins at the moment. So to continue I'll need to know which editor you are using? Vscode or nvim?

@joerdav joerdav added bug Something isn't working WaitingForMoreInfo labels May 20, 2024
@Jaimendo99
Copy link
Author

I'm currently using vscode

@joerdav joerdav changed the title LSP: Bad highlighting when using generic functions vscode: Bad highlighting when using generic functions May 21, 2024
@joerdav joerdav added vscode NeedsInvestigation Issue needs some investigation before being fixed and removed WaitingForMoreInfo labels May 21, 2024
@AlexanderArvidsson
Copy link

Highlights fine in neovim.
In Templ:
image

In Go:
image


Though, in my VSCode, it looks fine, the same as a normal go generic func.
In Templ:
image

In Go:
image


Neovim, highlights the generic part in both Templ and Go which vscode doesn't, but I think that's just cause neovim has better highlighting than vscode in Go in general thanks to tree sitter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working NeedsInvestigation Issue needs some investigation before being fixed vscode
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants