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

Xml syntax highlight #3479

Closed
sbergot opened this issue Aug 19, 2022 · 4 comments
Closed

Xml syntax highlight #3479

sbergot opened this issue Aug 19, 2022 · 4 comments
Labels
C-enhancement Category: Improvements

Comments

@sbergot
Copy link

sbergot commented Aug 19, 2022

I was surprised to see that there was no support for xml yet. I am willing to give a shot to adding syntax highlighting. Is it something doable for a rust newbie?

@sbergot sbergot added the C-enhancement Category: Improvements label Aug 19, 2022
@ChrHorn
Copy link
Contributor

ChrHorn commented Aug 19, 2022

You could try to just enable the html highlighting for xml files (in languages.toml).

Alternatively, there is also https://github.com/unhammer/tree-sitter-xml, but I don't know how good that implementation is.

@sbergot
Copy link
Author

sbergot commented Aug 19, 2022

@ChrHorn yes I was about to try that. Adding xml to the html file types works. It is good enough for me but it might be an issue for those who have the html language server enabled.

Anyway I am closing this. Thanks for the help!

edit: adding my configuration for future readers

[[language]]
name = "html"
file-types = ["html", "xml"]

@sbergot sbergot closed this as completed Aug 19, 2022
@kirawi
Copy link
Member

kirawi commented Aug 20, 2022

You can alternatively create a new language entry for XML that uses the syntax highlighting for HTML:

[[language]]
name = "xml"
scope = "scope.xml"
injection-regex = "xml"
file-types = ["xml"]
roots = []
indent = { tab-width = 2, unit = "  " }
grammar = "html"

You'll have to create a folder at runtime/queries/xml and create highlights.html and injections.scm files that contain:

;  inherits html

@tataue
Copy link

tataue commented Nov 9, 2023

You can alternatively create a new language entry for XML that uses the syntax highlighting for HTML:

[[language]]
name = "xml"
scope = "scope.xml"
injection-regex = "xml"
file-types = ["xml"]
roots = []
indent = { tab-width = 2, unit = "  " }
grammar = "html"

You'll have to create a folder at runtime/queries/xml and create highlights.html and injections.scm files that contain:

;  inherits html

just :set language html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: Improvements
Projects
None yet
Development

No branches or pull requests

4 participants