From f054a3f3ed445cdfa8c0dc63698659ef30af57b7 Mon Sep 17 00:00:00 2001 From: Matthew Toohey Date: Sat, 29 Oct 2022 16:41:28 -0400 Subject: [PATCH] feat(lang): add xml (#4518) --- 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 ++ 5 files changed, 66 insertions(+) create mode 100644 runtime/queries/xml/highlights.scm create mode 100644 runtime/queries/xml/indents.scm create mode 100644 runtime/queries/xml/injections.scm diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index ee54114a8..545ec635b 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 31a454b0c..00e6459de 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 000000000..d5940c8a0 --- /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 + +[ + "<" ">" "" "" "