aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--book/src/generated/lang-support.md1
-rw-r--r--languages.toml20
-rw-r--r--runtime/queries/xml/highlights.scm42
-rw-r--r--runtime/queries/xml/indents.scm1
-rw-r--r--runtime/queries/xml/injections.scm2
5 files changed, 66 insertions, 0 deletions
diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md
index ee54114a..545ec635 100644
--- a/book/src/generated/lang-support.md
+++ b/book/src/generated/lang-support.md
@@ -127,5 +127,6 @@
| wat | ✓ | | | |
| wgsl | ✓ | | | `wgsl_analyzer` |
| xit | ✓ | | | |
+| xml | ✓ | | ✓ | |
| yaml | ✓ | | ✓ | `yaml-language-server` |
| zig | ✓ | ✓ | ✓ | `zls` |
diff --git a/languages.toml b/languages.toml
index 31a454b0..00e6459d 100644
--- a/languages.toml
+++ b/languages.toml
@@ -1897,3 +1897,23 @@ injection-regex = "kdl"
[[grammar]]
name = "kdl"
source = { git = "https://github.com/Unoqwy/tree-sitter-kdl", rev = "e1cd292c6d15df6610484e1d4b5c987ecad52373" }
+
+[[language]]
+name = "xml"
+scope = "source.xml"
+injection-regex = "xml"
+file-types = ["xml"]
+indent = { tab-width = 2, unit = " " }
+roots = []
+
+[language.auto-pairs]
+'(' = ')'
+'{' = '}'
+'[' = ']'
+'"' = '"'
+"'" = "'"
+"<" = ">"
+
+[[grammar]]
+name = "xml"
+source = { git = "https://github.com/RenjiSann/tree-sitter-xml", rev = "422528a43630db6dcc1e222d1c5ee3babd559473" }
diff --git a/runtime/queries/xml/highlights.scm b/runtime/queries/xml/highlights.scm
new file mode 100644
index 00000000..d5940c8a
--- /dev/null
+++ b/runtime/queries/xml/highlights.scm
@@ -0,0 +1,42 @@
+(comment) @comment
+
+[
+ "DOCTYPE"
+ "ELEMENT"
+ "ATTLIST"
+] @keyword
+
+[
+ "#REQUIRED"
+ "#IMPLIED"
+ "#FIXED"
+ "#PCDATA"
+] @keyword.directive
+
+[
+ "EMPTY"
+ "ANY"
+ "SYSTEM"
+ "PUBLIC"
+] @constant
+
+(doctype) @variable
+(element_name) @variable
+
+"xml" @tag
+(tag_name) @tag
+
+[
+ "encoding"
+ "version"
+ "standalone"
+] @attribute
+(attribute_name) @attribute
+
+(system_literal) @string
+(pubid_literal) @string
+(attribute_value) @string
+
+[
+ "<" ">" "</" "/>" "<?" "?>" "<!"
+] @punctuation.bracket
diff --git a/runtime/queries/xml/indents.scm b/runtime/queries/xml/indents.scm
new file mode 100644
index 00000000..d756debb
--- /dev/null
+++ b/runtime/queries/xml/indents.scm
@@ -0,0 +1 @@
+(element) @indent
diff --git a/runtime/queries/xml/injections.scm b/runtime/queries/xml/injections.scm
new file mode 100644
index 00000000..321c90ad
--- /dev/null
+++ b/runtime/queries/xml/injections.scm
@@ -0,0 +1,2 @@
+((comment) @injection.content
+ (#set! injection.language "comment"))