Unnamed repository; edit this file 'description' to name the repository.
Switch svelte treesitter and update queries (#14343)
| -rw-r--r-- | languages.toml | 2 | ||||
| -rw-r--r-- | runtime/queries/svelte/folds.scm | 13 | ||||
| -rw-r--r-- | runtime/queries/svelte/highlights.scm | 72 | ||||
| -rw-r--r-- | runtime/queries/svelte/indents.scm | 22 | ||||
| -rw-r--r-- | runtime/queries/svelte/injections.scm | 61 | ||||
| -rw-r--r-- | runtime/queries/svelte/locals.scm | 1 |
6 files changed, 85 insertions, 86 deletions
diff --git a/languages.toml b/languages.toml index d8027ab1..a6197f57 100644 --- a/languages.toml +++ b/languages.toml @@ -1492,7 +1492,7 @@ language-servers = [ "svelteserver" ] [[grammar]] name = "svelte" -source = { git = "https://github.com/Himujjal/tree-sitter-svelte", rev = "60ea1d673a1a3eeeb597e098d9ada9ed0c79ef4b" } +source = { git = "https://github.com/tree-sitter-grammars/tree-sitter-svelte", rev = "ae5199db47757f785e43a14b332118a5474de1a2" } [[language]] name = "vue" diff --git a/runtime/queries/svelte/folds.scm b/runtime/queries/svelte/folds.scm new file mode 100644 index 00000000..6440301a --- /dev/null +++ b/runtime/queries/svelte/folds.scm @@ -0,0 +1,13 @@ +; inherits: html + +[ + (if_statement) + (else_if_block) + (else_block) + (each_statement) + (await_statement) + (then_block) + (catch_block) + (key_statement) + (snippet_statement) +] @fold diff --git a/runtime/queries/svelte/highlights.scm b/runtime/queries/svelte/highlights.scm index 7ab72903..efd41406 100644 --- a/runtime/queries/svelte/highlights.scm +++ b/runtime/queries/svelte/highlights.scm @@ -1,68 +1,38 @@ -; Special identifiers -;-------------------- +; inherits: html -(tag_name) @tag -(attribute_name) @variable.other.member -(erroneous_end_tag_name) @error -(comment) @comment +(raw_text) @none -; TODO: -((element (start_tag (tag_name) @_tag) (text) @markup.heading) - (#match? @_tag "^(h[0-9]|title)$")) - -((element (start_tag (tag_name) @_tag) (text) @markup.bold) - (#match? @_tag "^(strong|b)$")) - -((element (start_tag (tag_name) @_tag) (text) @markup.italic) - (#match? @_tag "^(em|i)$")) - -; ((element (start_tag (tag_name) @_tag) (text) @markup.strike) -; (#match? @_tag "^(s|del)$")) - -((element (start_tag (tag_name) @_tag) (text) @markup.underline) - (#eq? @_tag "u")) - -((element (start_tag (tag_name) @_tag) (text) @markup.inline) - (#match? @_tag "^(code|kbd)$")) - -((element (start_tag (tag_name) @_tag) (text) @markup.link.url) - (#eq? @_tag "a")) +[ + "as" + "key" + "html" + "debug" + "snippet" + "render" +] @keyword -((attribute - (attribute_name) @_attr - (quoted_attribute_value (attribute_value) @markup.link.url)) - (#match? @_attr "^(href|src)$")) +"const" @keyword.storage.modifier [ - (attribute_value) - (quoted_attribute_value) -] @string + "if" + "else if" + "else" + "then" + "await" +] @keyword.control.conditional -[ - (text) - (raw_text_expr) -] @none +"each" @keyword.control.repeat -[ - (special_block_keyword) - (then) - (as) -] @keyword +"catch" @keyword.control.exception [ "{" "}" -] @punctuation.brackets - -"=" @operator +] @punctuation.bracket [ - "<" - ">" - "</" - "/>" "#" ":" "/" "@" -] @punctuation.definition.tag +] @punctuation.delimiter diff --git a/runtime/queries/svelte/indents.scm b/runtime/queries/svelte/indents.scm index d0408d61..4bb103d7 100644 --- a/runtime/queries/svelte/indents.scm +++ b/runtime/queries/svelte/indents.scm @@ -1,18 +1,24 @@ [ (element) + (start_tag) (if_statement) + (else_if_block) + (else_block) + (then_block) (each_statement) + (key_statement) + (snippet_statement) (await_statement) - (script_element) (style_element) + (script_element) + (expression) ] @indent [ (end_tag) - (else_statement) - (if_end_expr) - (each_end_expr) - (await_end_expr) - ">" - "/>" -] @outdent
\ No newline at end of file + (if_end) + (each_end) + (await_end) + (key_end) + (snippet_end) +] @outdent diff --git a/runtime/queries/svelte/injections.scm b/runtime/queries/svelte/injections.scm index 52d430c3..b0903f61 100644 --- a/runtime/queries/svelte/injections.scm +++ b/runtime/queries/svelte/injections.scm @@ -1,40 +1,49 @@ -; injections.scm -; -------------- ((style_element (raw_text) @injection.content) (#set! injection.language "css")) ((style_element - (start_tag - (attribute - (attribute_name) @_attr - (quoted_attribute_value (attribute_value) @_lang))) - (raw_text) @injection.content) + (start_tag + (attribute + (attribute_name) @_attr + (quoted_attribute_value + (attribute_value) @_lang))) + (raw_text) @injection.content) (#eq? @_attr "lang") - (#match? @_lang "scss") + (#any-of? @_lang "scss" "postcss" "less") (#set! injection.language "scss")) -((attribute - (attribute_name) @_attr - (quoted_attribute_value (attribute_value) @css)) - (#eq? @_attr "style")) +((svelte_raw_text) @injection.content + (#set! injection.language "javascript")) -( - (script_element - (start_tag - (attribute - (quoted_attribute_value (attribute_value) @_lang))) - (raw_text) @injection.content) - (#match? @_lang "(ts|typescript)") - (#set! injection.language "typescript") -) +((script_element + (start_tag + (attribute + (attribute_name) @_attr + (quoted_attribute_value + (attribute_value) @_lang))) + (raw_text) @injection.content) + (#eq? @_attr "lang") + (#any-of? @_lang "ts" "typescript") + (#set! injection.language "typescript")) ((script_element + (start_tag + (attribute + (attribute_name) @_attr + (quoted_attribute_value + (attribute_value) @_lang))) (raw_text) @injection.content) + (#eq? @_attr "lang") + (#any-of? @_lang "js" "javascript") (#set! injection.language "javascript")) -((raw_text_expr) @injection.content - (#set! injection.language "javascript")) - -((comment) @injection.content - (#set! injection.language "comment")) +((element + (start_tag + (attribute + (attribute_name) @_attr + (quoted_attribute_value + (attribute_value) @injection.language))) + (text) @injection.content) + (#eq? @_attr "lang") + (#eq? @injection.language "pug")) diff --git a/runtime/queries/svelte/locals.scm b/runtime/queries/svelte/locals.scm new file mode 100644 index 00000000..1f2129cf --- /dev/null +++ b/runtime/queries/svelte/locals.scm @@ -0,0 +1 @@ +; inherits: html |