Debian Codegraph @

runtime/queries/vue/injections.scm

raw symbols SCIP
1 (directive_attribute
2 (directive_name) @keyword
3 (quoted_attribute_value
4 (attribute_value) @injection.content)
5 (#set! injection.language "javascript"))
6
7 ((interpolation
8 (raw_text) @injection.content)
9 (#set! injection.language "javascript"))
10
11 ; <script>
12 ((script_element
13 (start_tag) @_no_lang
14 (raw_text) @injection.content)
15 (#not-match? @_no_lang "lang=")
16 (#set! injection.language "javascript"))
17
18 ; <script lang="...">
19 ((script_element
20 (start_tag
21 (attribute
22 (attribute_name) @_attr_name
23 (quoted_attribute_value (attribute_value) @injection.language)))
24 (raw_text) @injection.content)
25 (#eq? @_attr_name "lang"))
26
27 ; <style>
28 ((style_element
29 (start_tag) @_no_lang
30 (raw_text) @injection.content)
31 (#not-match? @_no_lang "lang=")
32 (#set! injection.language "css"))
33
34 ; <style lang="...">
35 ((style_element
36 (start_tag
37 (attribute
38 (attribute_name) @_attr_name
39 (quoted_attribute_value (attribute_value) @injection.language)))
40 (raw_text) @injection.content)
41 (#eq? @_attr_name "lang"))
42
43 ; NOTE: <template> content is intentionally *not* injected. The tree-sitter-vue
44 ; grammar parses the template body natively as an HTML-like element tree
45 ; (`element`/`start_tag`/`directive_attribute`/`interpolation`/…), so it is
46 ; highlighted by vue's own `highlights.scm` — which understands Vue directives
47 ; (`v-if`, `:prop`, `@click`) that a plain HTML injection would not. A former
48 ; `(template_element (text) @injection.content) html` rule injected only the
49 ; loose inter-tag text fragments (never the tags), adding no highlighting while
50 ; breaking indentation: a caret at a `<template>`/element boundary landed in the
51 ; whitespace-only HTML sub-layer, so indent-on-type computed column 0. The
52 ; grammar parses the body as HTML elements regardless of any `lang="…"`
53 ; attribute, so an alternate template language (e.g. pug) cannot be injected over
54 ; it cleanly either.
55
56 ((comment) @injection.content
57 (#set! injection.language "comment"))