diff options
| author | BlockLune <39331194+BlockLune@users.noreply.github.com> | 2025-08-30 00:30:18 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-29 18:30:18 +0200 |
| commit | cd64fd3f448eb6cc529830c7f265f7584168572b (patch) | |
| tree | a017d25a103291d0e05b914486ac7d346a6ad341 /runtime | |
| parent | feat(matlab)!: update parser and queries (diff) | |
| download | nvim-treesitter-cd64fd3f448eb6cc529830c7f265f7584168572b.tar nvim-treesitter-cd64fd3f448eb6cc529830c7f265f7584168572b.tar.gz nvim-treesitter-cd64fd3f448eb6cc529830c7f265f7584168572b.tar.bz2 nvim-treesitter-cd64fd3f448eb6cc529830c7f265f7584168572b.tar.lz nvim-treesitter-cd64fd3f448eb6cc529830c7f265f7584168572b.tar.xz nvim-treesitter-cd64fd3f448eb6cc529830c7f265f7584168572b.tar.zst nvim-treesitter-cd64fd3f448eb6cc529830c7f265f7584168572b.zip | |
feat(wxml): add parser and queries
Diffstat (limited to 'runtime')
| -rw-r--r-- | runtime/queries/wxml/folds.scm | 7 | ||||
| -rw-r--r-- | runtime/queries/wxml/highlights.scm | 66 | ||||
| -rw-r--r-- | runtime/queries/wxml/indents.scm | 32 | ||||
| -rw-r--r-- | runtime/queries/wxml/injections.scm | 10 |
4 files changed, 115 insertions, 0 deletions
diff --git a/runtime/queries/wxml/folds.scm b/runtime/queries/wxml/folds.scm new file mode 100644 index 000000000..df3eeeef7 --- /dev/null +++ b/runtime/queries/wxml/folds.scm @@ -0,0 +1,7 @@ +[ + (element) + (block_element) + (slot_element) + (template_element) + (wxs_element) +] @fold diff --git a/runtime/queries/wxml/highlights.scm b/runtime/queries/wxml/highlights.scm new file mode 100644 index 000000000..5bdbd5d50 --- /dev/null +++ b/runtime/queries/wxml/highlights.scm @@ -0,0 +1,66 @@ +; Comments +(comment) @comment @spell + +; Text +(text) @spell + +; Tag names +(tag_name) @tag + +((tag_name) @tag.builtin + (#any-of? @tag.builtin "wxs" "template" "import" "include" "slot" "block")) + +; Attributes +(attribute_name) @tag.attribute + +(attribute_value) @string + +(quoted_attribute_value) @string + +; WeChat specific attributes +((attribute_name) @keyword.directive + (#lua-match? @keyword.directive "^wx:")) + +((attribute_name) @keyword.conditional + (#any-of? @keyword.conditional "wx:if" "wx:elif" "wx:else")) + +((attribute_name) @keyword.repeat + (#any-of? @keyword.repeat "wx:for" "wx:for-index" "wx:for-item")) + +((attribute_name) @keyword + (#lua-match? @keyword "^bind")) + +((attribute_name) @keyword + (#lua-match? @keyword "^catch")) + +((attribute_name) @keyword + (#lua-match? @keyword "^mut%-bind")) + +((attribute_name) @keyword + (#lua-match? @keyword "^model:")) + +((attribute_name) @keyword + (#lua-match? @keyword "^data-")) + +((attribute + (attribute_name) @_attr + (quoted_attribute_value) @string.special.url) + (#any-of? @_attr "href" "src") + (#offset! @string.special.url 0 1 0 -1)) + +; Entity references +(entity) @character.special + +; Interpolation delimiters +(interpolation_start) @punctuation.special + +(interpolation_end) @punctuation.special + +[ + "<" + ">" + "</" + "/>" +] @tag.delimiter + +"=" @operator diff --git a/runtime/queries/wxml/indents.scm b/runtime/queries/wxml/indents.scm new file mode 100644 index 000000000..30172bb37 --- /dev/null +++ b/runtime/queries/wxml/indents.scm @@ -0,0 +1,32 @@ +; inherits: html_tags + +(block_element) @indent.begin + +(template_element) @indent.begin + +(wxs_element) @indent.begin + +(block_element + (block_end_tag + ">" @indent.end)) + +(template_element + (template_end_tag + ">" @indent.end)) + +(wxs_element + (wxs_end_tag + ">" @indent.end)) + +(block_element + (block_end_tag) @indent.branch) + +(template_element + (template_end_tag) @indent.branch) + +(wxs_element + (wxs_end_tag) @indent.branch) + +(import_statement) @indent.ignore + +(include_statement) @indent.ignore diff --git a/runtime/queries/wxml/injections.scm b/runtime/queries/wxml/injections.scm new file mode 100644 index 000000000..09f615d38 --- /dev/null +++ b/runtime/queries/wxml/injections.scm @@ -0,0 +1,10 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +((raw_text) @injection.content + (#set! injection.language "javascript") + (#set! injection.include-children)) + +((expression) @injection.content + (#set! injection.language "javascript") + (#set! injection.include-children)) |
