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

Update readme to prevent breaking html systax highlighting #21

Closed
Olivier-Berg opened this issue Sep 17, 2024 · 4 comments · Fixed by #22
Closed

Update readme to prevent breaking html systax highlighting #21

Olivier-Berg opened this issue Sep 17, 2024 · 4 comments · Fixed by #22

Comments

@Olivier-Berg
Copy link

When using the instructions in the readme file, I got confused because when I created a .gotmpl the template code would get syntax highlighting but the highlighting of the html would break. I would suggest adding to the readme that in order for the gotmpl highlighting to work, one would need to add the file .config/nvim/queries/gotmpl/injections.scm:

(text) @yaml

((text) @injection.content
 (#set! injection.language "html")
 (#set! injection.combined))

((text) @injection.content
 (#set! injection.language "javascript")
 (#set! injection.combined))

to get the proper injections.

@qvalentin
Copy link
Collaborator

Good point, but from my understanding the snippet you posted does not really make sense.

(text) @yaml this has no effect i guess?

You also enabled both html and javascript injections at the same time, so the text nodes will be parsed with both parsers and the highlighting will be somewhat random (it is even flickering for me).
If your template files contain html and js it would be the best to use the js injections since this also supports jsx I guess.

Either way we can improve the readme and tell the user that he should add the injection for whatever language he is using inside the templates, sadly this can not be inferred from filetypes.

@Olivier-Berg
Copy link
Author

Olivier-Berg commented Sep 21, 2024

I took the snippet from the go.nvim plugin: https://github.com/ray-x/go.nvim/blob/master/queries/gotmpl/injections.scm but I guess it is incorrect then.

@qvalentin
Copy link
Collaborator

I opened a PR here and also for go.nvim

Feel free to check it out.

@Olivier-Berg
Copy link
Author

Great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants