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

generator: Implement the go line compiler directive in generated files #415

Open
joerdav opened this issue Jan 10, 2024 · 0 comments
Open
Labels
enhancement New feature or request generator NeedsFix Needs implementing

Comments

@joerdav
Copy link
Collaborator

joerdav commented Jan 10, 2024

There is a Go compiler directive //line, which can be used to reference other files. Historically gopls would support this directive, but subsequently dropped support golang/go#55043

There is an issue in gopls to propose reintroducing this golang/go#65001

It could be valuable for templ to implement this directive for the future, so that if this directive is implemented in gopls it'll work with generated templ files.

Solution

In *_templ.go files, all symbols that could be referenced by .go files should be defined with the //line directive, for example:

Generated file

//line index.templ:20
func Index() templ.Component {
...

This should apply to code generated by all keywords templ, css and script.

@joerdav joerdav changed the title Implement the go line compiler directive in generated files generator: Implement the go line compiler directive in generated files Jan 19, 2024
@joerdav joerdav added enhancement New feature or request generator labels Jan 19, 2024
@joerdav joerdav added the NeedsFix Needs implementing label Jan 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request generator NeedsFix Needs implementing
Projects
None yet
Development

No branches or pull requests

1 participant