on master help sign in
feat(lang): add xml (#4518)
commitf054a3f3ed445cdfa8c0dc63698659ef30af57b7 authorMatthew Toohey <contact@mtoohey.com> dateSat 29 Oct 2022, 16:41 (4 years ago) parent2935e9d
5 files changed+66
book/src/generated/lang-support.md+1 languages.toml+20 runtime/queries/xml/highlights.scm+42 runtime/queries/xml/indents.scm+1 runtime/queries/xml/injections.scm+2
book/src/generated/lang-support.md+1
@@ -127,5 +127,6 @@
127127| wat | ✓ | | | |
128128| wgsl | ✓ | | | `wgsl_analyzer` |
129129| xit | ✓ | | | |
130+| xml | ✓ | | ✓ | |
130131| yaml | ✓ | | ✓ | `yaml-language-server` |
131132| zig | ✓ | ✓ | ✓ | `zls` |
languages.toml+20
@@ -1897,3 +1897,23 @@ injection-regex = "kdl"
18971897[[grammar]]
18981898name = "kdl"
18991899source = { git = "https://github.com/Unoqwy/tree-sitter-kdl", rev = "e1cd292c6d15df6610484e1d4b5c987ecad52373" }
1900+
1901+[[language]]
1902+name = "xml"
1903+scope = "source.xml"
1904+injection-regex = "xml"
1905+file-types = ["xml"]
1906+indent = { tab-width = 2, unit = " " }
1907+roots = []
1908+
1909+[language.auto-pairs]
1910+'(' = ')'
1911+'{' = '}'
1912+'[' = ']'
1913+'"' = '"'
1914+"'" = "'"
1915+"<" = ">"
1916+
1917+[[grammar]]
1918+name = "xml"
1919+source = { git = "https://github.com/RenjiSann/tree-sitter-xml", rev = "422528a43630db6dcc1e222d1c5ee3babd559473" }
runtime/queries/xml/highlights.scmnew file+42
@@ -0,0 +1,42 @@
1+(comment) @comment
2+
3+[
4+ "DOCTYPE"
5+ "ELEMENT"
6+ "ATTLIST"
7+] @keyword
8+
9+[
10+ "#REQUIRED"
11+ "#IMPLIED"
12+ "#FIXED"
13+ "#PCDATA"
14+] @keyword.directive
15+
16+[
17+ "EMPTY"
18+ "ANY"
19+ "SYSTEM"
20+ "PUBLIC"
21+] @constant
22+
23+(doctype) @variable
24+(element_name) @variable
25+
26+"xml" @tag
27+(tag_name) @tag
28+
29+[
30+ "encoding"
31+ "version"
32+ "standalone"
33+] @attribute
34+(attribute_name) @attribute
35+
36+(system_literal) @string
37+(pubid_literal) @string
38+(attribute_value) @string
39+
40+[
41+ "<" ">" "</" "/>" "<?" "?>" "<!"
42+] @punctuation.bracket
runtime/queries/xml/indents.scmnew file+1
@@ -0,0 +1 @@
1+(element) @indent
runtime/queries/xml/injections.scmnew file+2
@@ -0,0 +1,2 @@
1+((comment) @injection.content
2+ (#set! injection.language "comment"))