mirror of
https://github.com/chenasraf/nvim-treesitter.git
synced 2026-05-18 01:39:00 +00:00
chore(injections)!: update injection syntax to 0.9
Since 0.9, @lang syntax is still available as fallback but will soon be deprecated. Because of that, new syntax should be adopted once 0.9 becomes the baseline requirements for nvim-treesitter - update health check - update doc
This commit is contained in:
committed by
Christian Clason
parent
2aa9e9b0e6
commit
78b54eb7f6
@@ -318,19 +318,32 @@ query.
|
||||
### Injections
|
||||
|
||||
Some captures are related to language injection (like markdown code blocks). They are used in `injections.scm`.
|
||||
You can directly use the name of the language that you want to inject (e.g. `@html` to inject html).
|
||||
|
||||
If you want to dynamically detect the language (e.g. for Markdown blocks) use the `@language` to capture
|
||||
the node describing the language and `@content` to describe the injection region.
|
||||
If you want to dynamically detect the language (e.g. for Markdown blocks) use the `@injection.language` to capture
|
||||
the node describing the language and `@injection.content` to describe the injection region.
|
||||
|
||||
```scheme
|
||||
@{lang} ; e.g. @html to describe a html region
|
||||
|
||||
@language ; dynamic detection of the injection language (i.e. the text of the captured node describes the language)
|
||||
@content ; region for the dynamically detected language
|
||||
@combined ; combine all matches of a pattern as one single block of content
|
||||
@injection.language ; dynamic detection of the injection language (i.e. the text of the captured node describes the language)
|
||||
@injection.content ; region for the dynamically detected language
|
||||
```
|
||||
|
||||
For example, to inject javascript into HTML's `<script>` tag
|
||||
|
||||
```html
|
||||
<script>someJsCode();</script>
|
||||
```
|
||||
|
||||
```query
|
||||
(script_element
|
||||
(raw_text) @injection.content
|
||||
(#set! injection.language "javascript")) ; set the parser language for @injection.content region to javascript
|
||||
```
|
||||
|
||||
For regions that don't have a corresponding `@injection.language`, you need to manually set the language
|
||||
through `(#set injection.language "lang_name")`
|
||||
|
||||
To combine all matches of a pattern as one single block of content, add `(#set! injection.combined)` to such pattern
|
||||
|
||||
### Indents
|
||||
|
||||
```scheme
|
||||
|
||||
@@ -153,10 +153,10 @@ query.add_directive("set-lang-from-mimetype!", function(match, _, bufnr, pred, m
|
||||
local type_attr_value = vim.treesitter.get_node_text(node, bufnr)
|
||||
local configured = html_script_type_languages[type_attr_value]
|
||||
if configured then
|
||||
metadata.language = configured
|
||||
metadata["injection.language"] = configured
|
||||
else
|
||||
local parts = vim.split(type_attr_value, "/", {})
|
||||
metadata.language = parts[#parts]
|
||||
metadata["injection.language"] = parts[#parts]
|
||||
end
|
||||
end, true)
|
||||
|
||||
@@ -172,7 +172,7 @@ query.add_directive("set-lang-from-info-string!", function(match, _, bufnr, pred
|
||||
return
|
||||
end
|
||||
local injection_alias = vim.treesitter.get_node_text(node, bufnr)
|
||||
metadata.language = get_parser_from_markdown_info_string(injection_alias)
|
||||
metadata["injection.language"] = get_parser_from_markdown_info_string(injection_alias)
|
||||
end, true)
|
||||
|
||||
-- Just avoid some annoying warnings for this directive
|
||||
@@ -211,37 +211,6 @@ query.add_directive("downcase!", function(match, _, bufnr, pred, metadata)
|
||||
end
|
||||
end, true)
|
||||
|
||||
---@param match (TSNode|nil)[]
|
||||
---@param _pattern string
|
||||
---@param _bufnr integer
|
||||
---@param pred string[]
|
||||
---@param metadata table
|
||||
---@return boolean|nil
|
||||
query.add_directive("exclude_children!", function(match, _pattern, _bufnr, pred, metadata)
|
||||
local capture_id = pred[2]
|
||||
local node = match[capture_id]
|
||||
local start_row, start_col, end_row, end_col = node:range()
|
||||
local ranges = {}
|
||||
for i = 0, node:named_child_count() - 1 do
|
||||
local child = node:named_child(i) ---@type TSNode
|
||||
local child_start_row, child_start_col, child_end_row, child_end_col = child:range()
|
||||
if child_start_row > start_row or child_start_col > start_col then
|
||||
table.insert(ranges, {
|
||||
start_row,
|
||||
start_col,
|
||||
child_start_row,
|
||||
child_start_col,
|
||||
})
|
||||
end
|
||||
start_row = child_end_row
|
||||
start_col = child_end_col
|
||||
end
|
||||
if end_row > start_row or end_col > start_col then
|
||||
table.insert(ranges, { start_row, start_col, end_row, end_col })
|
||||
end
|
||||
metadata.content = ranges
|
||||
end, true)
|
||||
|
||||
-- Trim blank lines from end of the region
|
||||
-- Arguments are the captures to trim.
|
||||
---@param match (TSNode|nil)[]
|
||||
|
||||
@@ -1,6 +1,15 @@
|
||||
((preproc_def (preproc_arg) @arduino)
|
||||
(#lua-match? @arduino "\n"))
|
||||
(preproc_function_def (preproc_arg) @arduino)
|
||||
(preproc_call (preproc_arg) @arduino)
|
||||
((preproc_def
|
||||
(preproc_arg) @injection.content)
|
||||
(#lua-match? @injection.content "\n")
|
||||
(#set! injection.language "arduino"))
|
||||
|
||||
(comment) @comment
|
||||
(preproc_function_def
|
||||
(preproc_arg) @injection.content
|
||||
(#set! injection.language "arduino"))
|
||||
|
||||
(preproc_call
|
||||
(preproc_arg) @injection.content
|
||||
(#set! injection.language "arduino"))
|
||||
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
@@ -1,19 +1,23 @@
|
||||
; inherits: html
|
||||
; inherits: html_tags
|
||||
|
||||
((frontmatter
|
||||
(raw_text) @typescript))
|
||||
(frontmatter
|
||||
(raw_text) @injection.content
|
||||
(#set! injection.language "typescript"))
|
||||
|
||||
((interpolation
|
||||
(raw_text) @tsx))
|
||||
(interpolation
|
||||
(raw_text) @injection.content
|
||||
(#set! injection.language "tsx"))
|
||||
|
||||
((script_element
|
||||
(raw_text) @typescript))
|
||||
(script_element
|
||||
(raw_text) @injection.content
|
||||
(#set! injection.language "typescript"))
|
||||
|
||||
((style_element
|
||||
(start_tag
|
||||
(attribute
|
||||
(attribute_name) @_lang_attr
|
||||
(quoted_attribute_value (attribute_value) @_lang_value)))
|
||||
(raw_text) @scss)
|
||||
(style_element
|
||||
(start_tag
|
||||
(attribute
|
||||
(attribute_name) @_lang_attr
|
||||
(quoted_attribute_value (attribute_value) @_lang_value)))
|
||||
(raw_text) @injection.content
|
||||
(#eq? @_lang_attr "lang")
|
||||
(#eq? @_lang_value "scss"))
|
||||
(#eq? @_lang_value "scss")
|
||||
(#set! injection.language "scss"))
|
||||
|
||||
@@ -1,2 +1,5 @@
|
||||
(comment) @comment
|
||||
(regex) @regex
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
((regex) @injection.content
|
||||
(#set! injection.language "regex"))
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
(comment) @comment
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
(regex) @regex
|
||||
((regex) @injection.content
|
||||
(#set! injection.language "regex"))
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
(comment) @comment
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
[
|
||||
(comment)
|
||||
(diagnostic_comment)
|
||||
] @comment
|
||||
([
|
||||
(comment)
|
||||
(diagnostic_comment)
|
||||
] @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
@@ -1,10 +1,21 @@
|
||||
((preproc_def (preproc_arg) @c)
|
||||
(#lua-match? @c "\n"))
|
||||
(preproc_function_def (preproc_arg) @c)
|
||||
(preproc_call (preproc_arg) @c)
|
||||
((preproc_def
|
||||
(preproc_arg) @injection.content)
|
||||
(#lua-match? @injection.content "\n")
|
||||
(#set! injection.language "c"))
|
||||
|
||||
(comment) @comment
|
||||
(preproc_function_def
|
||||
(preproc_arg) @injection.content
|
||||
(#set! injection.language "c"))
|
||||
|
||||
(preproc_call
|
||||
(preproc_arg) @injection.content
|
||||
(#set! injection.language "c"))
|
||||
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
; TODO: add when asm is added
|
||||
; (gnu_asm_expression assembly_code: (string_literal) @asm)
|
||||
; (gnu_asm_expression assembly_code: (concatenated_string (string_literal) @asm))
|
||||
; (gnu_asm_expression assembly_code: (string_literal) @injection.content
|
||||
; (#set! injection.language "asm"))
|
||||
; (gnu_asm_expression assembly_code: (concatenated_string (string_literal) @injection.content)
|
||||
; (#set! injection.language "asm"))
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
(comment) @comment
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
(comment) @comment
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
(comment) @comment
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
(comment) @comment
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
(comment) @comment
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
@@ -1,10 +1,19 @@
|
||||
((preproc_def (preproc_arg) @cpp)
|
||||
(#lua-match? @cpp "\n"))
|
||||
(preproc_function_def (preproc_arg) @cpp)
|
||||
(preproc_call (preproc_arg) @cpp)
|
||||
((preproc_def
|
||||
(preproc_arg) @injection.content)
|
||||
(#lua-match? @injection.content "\n")
|
||||
(#set! injection.language "cpp"))
|
||||
|
||||
(comment) @comment
|
||||
(preproc_function_def
|
||||
(preproc_arg) @injection.content
|
||||
(#set! injection.language "cpp"))
|
||||
|
||||
(preproc_call
|
||||
(preproc_arg) @injection.content
|
||||
(#set! injection.language "cpp"))
|
||||
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
(raw_string_literal
|
||||
delimiter: (raw_string_delimiter) @language
|
||||
(raw_string_content) @content)
|
||||
delimiter: (raw_string_delimiter) @injection.language
|
||||
(raw_string_content) @injection.content)
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
(comment) @comment
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
@@ -1,6 +1,15 @@
|
||||
((preproc_def (preproc_arg) @cuda)
|
||||
(#lua-match? @cuda "\n"))
|
||||
(preproc_function_def (preproc_arg) @cuda)
|
||||
(preproc_call (preproc_arg) @cuda)
|
||||
((preproc_def
|
||||
(preproc_arg) @injection.content)
|
||||
(#lua-match? @injection.content "\n")
|
||||
(#set! injection.language "cuda"))
|
||||
|
||||
(comment) @comment
|
||||
(preproc_function_def
|
||||
(preproc_arg) @injection.content
|
||||
(#set! injection.language "cuda"))
|
||||
|
||||
(preproc_call
|
||||
(preproc_arg) @injection.content
|
||||
(#set! injection.language "cuda"))
|
||||
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
(comment) @comment
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
[
|
||||
([
|
||||
(line_comment)
|
||||
(block_comment)
|
||||
(nesting_block_comment)
|
||||
] @comment
|
||||
] @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
(token_string_tokens) @d
|
||||
((token_string_tokens) @injection.content
|
||||
(#set! injection.language "d"))
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
(comment) @comment
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
(comment) @comment
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
[
|
||||
([
|
||||
(line_comment)
|
||||
(block_comment)
|
||||
] @comment
|
||||
] @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
(comment) @comment
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
(shell_command) @bash
|
||||
((shell_command) @injection.content
|
||||
(#set! injection.language "bash"))
|
||||
|
||||
@@ -1,2 +1,5 @@
|
||||
(html_internal) @html
|
||||
(comment) @comment
|
||||
((html_internal) @injection.content
|
||||
(#set! injection.language "html"))
|
||||
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
@@ -1,59 +1,67 @@
|
||||
(((comment) @_jsdoc_comment
|
||||
(#lua-match? @_jsdoc_comment "^/[*][*][^*].*[*]/$")) @jsdoc)
|
||||
(#lua-match? @_jsdoc_comment "^/[*][*][^*].*[*]/$")) @injection.content
|
||||
(#set! injection.language "jsdoc"))
|
||||
|
||||
(comment) @comment
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
; html(`...`), html`...`, sql(...) etc
|
||||
(call_expression
|
||||
function: ((identifier) @language)
|
||||
function: ((identifier) @injection.language)
|
||||
arguments: [
|
||||
(arguments
|
||||
(template_string) @content)
|
||||
(template_string) @content
|
||||
(template_string) @injection.content)
|
||||
(template_string) @injection.content
|
||||
]
|
||||
(#offset! @content 0 1 0 -1)
|
||||
(#not-eq? @content "svg"))
|
||||
(#offset! @injection.content 0 1 0 -1)
|
||||
(#not-eq? @injection.language "svg"))
|
||||
|
||||
; svg`...` or svg(`...`), which uses the html parser, so is not included in the previous query
|
||||
(call_expression
|
||||
function: ((identifier) @_name (#eq? @_name "svg"))
|
||||
arguments: [
|
||||
(arguments
|
||||
(template_string) @html)
|
||||
(template_string) @html
|
||||
(template_string) @injection.content)
|
||||
(template_string) @injection.content
|
||||
]
|
||||
(#offset! @html 0 1 0 -1))
|
||||
(#offset! @injection.content 0 1 0 -1)
|
||||
(#set! injection.language "html"))
|
||||
|
||||
|
||||
(call_expression
|
||||
function: ((identifier) @_name
|
||||
(#eq? @_name "gql"))
|
||||
arguments: ((template_string) @graphql
|
||||
(#offset! @graphql 0 1 0 -1)))
|
||||
arguments: ((template_string) @injection.content
|
||||
(#offset! @injection.content 0 1 0 -1)
|
||||
(#set! injection.language "graphql")))
|
||||
|
||||
(call_expression
|
||||
function: ((identifier) @_name
|
||||
(#eq? @_name "hbs"))
|
||||
arguments: ((template_string) @glimmer
|
||||
(#offset! @glimmer 0 1 0 -1)))
|
||||
arguments: ((template_string) @injection.content
|
||||
(#offset! @injection.content 0 1 0 -1)
|
||||
(#set! injection.language "glimmer")))
|
||||
|
||||
((glimmer_template) @glimmer)
|
||||
((glimmer_template) @injection.content
|
||||
(#set! injection.language "glimmer"))
|
||||
|
||||
; styled.div`<css>`
|
||||
(call_expression
|
||||
function: (member_expression
|
||||
object: (identifier) @_name
|
||||
(#eq? @_name "styled"))
|
||||
arguments: ((template_string) @css
|
||||
(#offset! @css 0 1 0 -1)))
|
||||
arguments: ((template_string) @injection.content
|
||||
(#offset! @injection.content 0 1 0 -1)
|
||||
(#set! injection.language "css")))
|
||||
|
||||
; styled(Component)`<css>`
|
||||
(call_expression
|
||||
function: (call_expression
|
||||
function: (identifier) @_name
|
||||
(#eq? @_name "styled"))
|
||||
arguments: ((template_string) @css
|
||||
(#offset! @css 0 1 0 -1)))
|
||||
arguments: ((template_string) @injection.content
|
||||
(#offset! @injection.content 0 1 0 -1)
|
||||
(#set! injection.language "css")))
|
||||
|
||||
; styled.div.attrs({ prop: "foo" })`<css>`
|
||||
(call_expression
|
||||
@@ -62,8 +70,9 @@
|
||||
object: (member_expression
|
||||
object: (identifier) @_name
|
||||
(#eq? @_name "styled"))))
|
||||
arguments: ((template_string) @css
|
||||
(#offset! @css 0 1 0 -1)))
|
||||
arguments: ((template_string) @injection.content
|
||||
(#offset! @injection.content 0 1 0 -1)
|
||||
(#set! injection.language "css")))
|
||||
|
||||
|
||||
; styled(Component).attrs({ prop: "foo" })`<css>`
|
||||
@@ -73,31 +82,34 @@
|
||||
object: (call_expression
|
||||
function: (identifier) @_name
|
||||
(#eq? @_name "styled"))))
|
||||
arguments: ((template_string) @css
|
||||
(#offset! @css 0 1 0 -1)))
|
||||
arguments: ((template_string) @injection.content
|
||||
(#offset! @injection.content 0 1 0 -1)
|
||||
(#set! injection.language "css")))
|
||||
|
||||
(regex_pattern) @regex
|
||||
((regex_pattern) @injection.content
|
||||
(#set! injection.language "regex"))
|
||||
|
||||
; ((comment) @_gql_comment
|
||||
; (#eq? @_gql_comment "/* GraphQL */")
|
||||
; (template_string) @graphql)
|
||||
; (template_string) @injection.content
|
||||
; (#set! injection.language "graphql"))
|
||||
|
||||
((template_string) @graphql
|
||||
(#lua-match? @graphql "^`#graphql")
|
||||
(#offset! @graphql 0 1 0 -1))
|
||||
((template_string) @injection.content
|
||||
(#lua-match? @injection.content "^`#graphql")
|
||||
(#offset! @injection.content 0 1 0 -1)
|
||||
(#set! injection.language "graphql"))
|
||||
|
||||
; el.innerHTML = `<html>`
|
||||
(assignment_expression
|
||||
left: (member_expression
|
||||
property: (property_identifier) @_prop
|
||||
(#any-of? @_prop "innerHTML" "outerHTML"))
|
||||
right: (template_string) @html
|
||||
(#offset! @html 0 1 0 -1))
|
||||
|
||||
; el.innerHTML = '<html>'
|
||||
(assignment_expression
|
||||
left: (member_expression
|
||||
property: (property_identifier) @_prop
|
||||
(#any-of? @_prop "innerHTML" "outerHTML"))
|
||||
right: (string) @html
|
||||
(#offset! @html 0 1 0 -1))
|
||||
left:
|
||||
(member_expression
|
||||
property: (property_identifier) @_prop
|
||||
(#any-of? @_prop "outerHTML" "innerHTML"))
|
||||
right:
|
||||
[
|
||||
(template_string)
|
||||
(string)
|
||||
] @injection.content
|
||||
(#offset! @injection.content 0 1 0 -1)
|
||||
(#set! injection.language "html"))
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
; EEx expressions are Elixir
|
||||
(expression) @elixir
|
||||
((expression) @injection.content
|
||||
(#set! injection.language "elixir"))
|
||||
|
||||
; EEx expressions can span multiple interpolated lines
|
||||
(partial_expression) @elixir @combined
|
||||
((partial_expression) @injection.content
|
||||
(#set! injection.language "elixir")
|
||||
(#set! injection.combined))
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
; Comments
|
||||
(comment) @comment
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
; Documentation
|
||||
(unary_operator
|
||||
@@ -7,42 +8,49 @@
|
||||
operand: (call
|
||||
target: ((identifier) @_identifier (#any-of? @_identifier "moduledoc" "typedoc" "shortdoc" "doc"))
|
||||
(arguments [
|
||||
(string (quoted_content) @markdown)
|
||||
(sigil (quoted_content) @markdown)
|
||||
])))
|
||||
(string (quoted_content) @injection.content)
|
||||
(sigil (quoted_content) @injection.content)
|
||||
])
|
||||
(#set! injection.language "markdown")))
|
||||
|
||||
; HEEx
|
||||
(sigil
|
||||
(sigil_name) @_sigil_name
|
||||
(quoted_content) @heex
|
||||
(#eq? @_sigil_name "H"))
|
||||
(quoted_content) @injection.content
|
||||
(#eq? @_sigil_name "H")
|
||||
(#set! injection.language "heex"))
|
||||
|
||||
; Surface
|
||||
(sigil
|
||||
(sigil_name) @_sigil_name
|
||||
(quoted_content) @surface
|
||||
(#eq? @_sigil_name "F"))
|
||||
(quoted_content) @injection.content
|
||||
(#eq? @_sigil_name "F")
|
||||
(#set! injection.language "surface"))
|
||||
|
||||
; Zigler
|
||||
(sigil
|
||||
(sigil_name) @_sigil_name
|
||||
(quoted_content) @eex
|
||||
(#any-of? @_sigil_name "E" "L"))
|
||||
(quoted_content) @injection.content
|
||||
(#any-of? @_sigil_name "E" "L")
|
||||
(#set! injection.language "eex"))
|
||||
|
||||
(sigil
|
||||
(sigil_name) @_sigil_name
|
||||
(quoted_content) @zig
|
||||
(#any-of? @_sigil_name "z" "Z"))
|
||||
(quoted_content) @injection.content
|
||||
(#any-of? @_sigil_name "z" "Z")
|
||||
(#set! injection.language "zig"))
|
||||
|
||||
; Regex
|
||||
(sigil
|
||||
(sigil_name) @_sigil_name
|
||||
(quoted_content) @regex
|
||||
(#any-of? @_sigil_name "r" "R"))
|
||||
(quoted_content) @injection.content
|
||||
(#any-of? @_sigil_name "r" "R")
|
||||
(#set! injection.language "regex"))
|
||||
|
||||
; Jason
|
||||
; Json
|
||||
(sigil
|
||||
(sigil_name) @_sigil_name
|
||||
(quoted_content) @json
|
||||
(#any-of? @_sigil_name "j" "J"))
|
||||
(quoted_content) @injection.content
|
||||
(#any-of? @_sigil_name "j" "J")
|
||||
(#set! injection.language "json"))
|
||||
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
[(line_comment) (block_comment)] @comment
|
||||
([
|
||||
(line_comment)
|
||||
(block_comment)
|
||||
] @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
(glsl_content) @glsl
|
||||
((glsl_content) @injection.content
|
||||
(#set! injection.language "glsl"))
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
(comment) @comment
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
(comment) @comment
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
@@ -1,2 +1,7 @@
|
||||
(content) @html @combined
|
||||
(code) @ruby @combined
|
||||
((content) @injection.content
|
||||
(#set! injection.language "html")
|
||||
(#set! injection.combined))
|
||||
|
||||
((code) @injection.content
|
||||
(#set! injection.language "ruby")
|
||||
(#set! injection.combined))
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
(comment) @comment
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
(comment) @comment
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
(comment) @comment
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
@@ -1,12 +1,20 @@
|
||||
;; Pass code blocks to Cpp highlighter
|
||||
(code (code_body) @cpp)
|
||||
(code
|
||||
(code_body) @injection.content
|
||||
(#set! injection.language "cpp"))
|
||||
|
||||
;; Pass identifiers to Go highlighter (Cheating I know)
|
||||
;;((identifier) @lua)
|
||||
;; ((identifier) @injection.content
|
||||
;; (#set! injection.language "lua")
|
||||
|
||||
;; Highlight regex syntax inside literal strings
|
||||
((string_literal) @regex)
|
||||
((string_literal) @injection.content
|
||||
(#set! injection.language "regex"))
|
||||
|
||||
;; Highlight PyFoam syntax as Python statements
|
||||
(pyfoam_variable code_body: (_) @python)
|
||||
(pyfoam_expression code_body: (_) @python)
|
||||
(pyfoam_variable
|
||||
code_body: (_) @injection.content
|
||||
(#set! injection.language "python"))
|
||||
(pyfoam_expression
|
||||
code_body: (_) @injection.content
|
||||
(#set! injection.language "python"))
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
(comment) @comment
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
((operation
|
||||
(command) @_command
|
||||
(message) @bash)
|
||||
(message) @injection.content)
|
||||
(#set! injection.language "bash")
|
||||
(#any-of? @_command "exec" "x"))
|
||||
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
(comment) @comment
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
@@ -1,2 +1,5 @@
|
||||
((diff) @diff (#exclude_children! @diff))
|
||||
(rebase_command) @git_rebase
|
||||
((diff) @injection.content
|
||||
(#set! injection.language "diff"))
|
||||
|
||||
((rebase_command) @injection.content
|
||||
(#set! injection.language "git_rebase"))
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
; Comments
|
||||
[
|
||||
([
|
||||
(module_comment)
|
||||
(statement_comment)
|
||||
(comment)
|
||||
] @comment
|
||||
] @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
@@ -1,6 +1,15 @@
|
||||
((preproc_def (preproc_arg) @glsl)
|
||||
(#lua-match? @glsl "\n"))
|
||||
(preproc_function_def (preproc_arg) @glsl)
|
||||
(preproc_call (preproc_arg) @glsl)
|
||||
((preproc_def
|
||||
(preproc_arg) @injection.content)
|
||||
(#lua-match? @injection.content "\n")
|
||||
(#set! injection.language "glsl"))
|
||||
|
||||
(comment) @comment
|
||||
(preproc_function_def
|
||||
(preproc_arg) @injection.content
|
||||
(#set! injection.language "glsl"))
|
||||
|
||||
(preproc_call
|
||||
(preproc_arg) @injection.content
|
||||
(#set! injection.language "glsl"))
|
||||
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
(comment) @comment
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
(call_expression
|
||||
(selector_expression) @_function (#any-of? @_function
|
||||
@@ -10,4 +11,10 @@
|
||||
"regexp.MustCompile"
|
||||
"regexp.MustCompilePOSIX")
|
||||
(argument_list
|
||||
. [(raw_string_literal) (interpreted_string_literal)] @regex (#offset! @regex 0 1 0 -1)))
|
||||
.
|
||||
[
|
||||
(raw_string_literal)
|
||||
(interpreted_string_literal)
|
||||
] @injection.content
|
||||
(#offset! @injection.content 0 1 0 -1)
|
||||
(#set! injection.language "regex")))
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
(comment) @comment
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
(comment) @comment
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
(comment) @comment
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
[
|
||||
(block_comment)
|
||||
(line_comment)
|
||||
] @comment
|
||||
((line_comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
((block_comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
(comment) @comment
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
((call_expression
|
||||
. (_) @_fnname
|
||||
. "("
|
||||
. (_ [(string_content) (raw_string_content)] @regex)
|
||||
. (_ [(string_content) (raw_string_content)] @injection.content)
|
||||
. ")")
|
||||
(#any-of? @_fnname "compile" "regex::compile"))
|
||||
(#any-of? @_fnname "compile" "regex::compile")
|
||||
(#set! injection.language "regex"))
|
||||
|
||||
@@ -2,11 +2,12 @@
|
||||
;; General language injection
|
||||
|
||||
(quasiquote
|
||||
((quoter) @language)
|
||||
((quasiquote_body) @content)
|
||||
((quoter) @injection.language)
|
||||
((quasiquote_body) @injection.content)
|
||||
)
|
||||
|
||||
(comment) @comment
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
;; -----------------------------------------------------------------------------
|
||||
;; shakespeare library
|
||||
@@ -17,35 +18,36 @@
|
||||
; (quasiquote
|
||||
; (quoter) @_name
|
||||
; (#eq? @_name "coffee")
|
||||
; ((quasiquote_body) @coffeescript)
|
||||
; ((quasiquote_body) @injection.content
|
||||
; (#set! injection.language "coffeescript")))
|
||||
|
||||
; CSS: Text.Cassius, Text.Lucius
|
||||
(quasiquote
|
||||
(quoter) @_name
|
||||
(#any-of? @_name "cassius" "lucius")
|
||||
((quasiquote_body) @css)
|
||||
)
|
||||
((quasiquote_body) @injection.content)
|
||||
(#set! injection.language "css"))
|
||||
|
||||
; HTML: Text.Hamlet
|
||||
(quasiquote
|
||||
(quoter) @_name
|
||||
(#any-of? @_name "shamlet" "xshamlet" "hamlet" "xhamlet" "ihamlet")
|
||||
((quasiquote_body) @html)
|
||||
)
|
||||
((quasiquote_body) @injection.content)
|
||||
(#set! injection.language "html"))
|
||||
|
||||
; JS: Text.Julius
|
||||
(quasiquote
|
||||
(quoter) @_name
|
||||
(#any-of? @_name "js" "julius")
|
||||
((quasiquote_body) @javascript)
|
||||
)
|
||||
((quasiquote_body) @injection.content)
|
||||
(#set! injection.language "javascript"))
|
||||
|
||||
; TS: Text.TypeScript
|
||||
(quasiquote
|
||||
(quoter) @_name
|
||||
(#any-of? @_name "tsc" "tscJSX")
|
||||
((quasiquote_body) @typescript)
|
||||
)
|
||||
((quasiquote_body) @injection.content)
|
||||
(#set! injection.language "typescript"))
|
||||
|
||||
|
||||
;; -----------------------------------------------------------------------------
|
||||
@@ -54,8 +56,8 @@
|
||||
(quasiquote
|
||||
(quoter) @_name
|
||||
(#eq? @_name "hsx")
|
||||
((quasiquote_body) @html)
|
||||
)
|
||||
((quasiquote_body) @injection.content)
|
||||
(#set! injection.language "html"))
|
||||
|
||||
;; -----------------------------------------------------------------------------
|
||||
;; Inline JSON from aeson
|
||||
@@ -63,8 +65,8 @@
|
||||
(quasiquote
|
||||
(quoter) @_name
|
||||
(#eq? @_name "aesonQQ")
|
||||
((quasiquote_body) @json)
|
||||
)
|
||||
((quasiquote_body) @injection.content)
|
||||
(#set! injection.language "json"))
|
||||
|
||||
|
||||
;; -----------------------------------------------------------------------------
|
||||
@@ -72,14 +74,12 @@
|
||||
|
||||
; postgresql-simple
|
||||
(quasiquote
|
||||
(quoter) @_name
|
||||
(#eq? @_name "sql")
|
||||
((quasiquote_body) @sql)
|
||||
)
|
||||
(quoter) @injection.language
|
||||
(#eq? @injection.language "sql")
|
||||
((quasiquote_body) @injection.content))
|
||||
|
||||
; persistent
|
||||
(quasiquote
|
||||
(quoter) @_name
|
||||
(#any-of? @_name "persistUpperCase" "persistLowerCase" "persistWith")
|
||||
((quasiquote_body) @haskell_persistent)
|
||||
)
|
||||
(quoter) @_name
|
||||
(#any-of? @_name "persistUpperCase" "persistLowerCase" "persistWith")
|
||||
((quasiquote_body) @injection.content)
|
||||
(#set! injection.language "haskell_persistent"))
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
(comment) @comment
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
(heredoc_template
|
||||
(template_literal) @content
|
||||
(heredoc_identifier) @language
|
||||
(#set! "language" @language)
|
||||
(#downcase! "language"))
|
||||
(template_literal) @injection.content
|
||||
(heredoc_identifier) @injection.language
|
||||
(#downcase! @injection.language))
|
||||
|
||||
@@ -2,10 +2,15 @@
|
||||
(directive [
|
||||
(expression_value)
|
||||
(partial_expression_value)
|
||||
] @elixir @combined)
|
||||
] @injection.content
|
||||
(#set! injection.language "elixir")
|
||||
(#set! injection.combined))
|
||||
|
||||
; HEEx Elixir expressions are always within a tag or component
|
||||
(expression (expression_value) @elixir)
|
||||
(expression
|
||||
(expression_value) @injection.content
|
||||
(#set! injection.language "elixir"))
|
||||
|
||||
; HEEx comments
|
||||
(comment) @comment
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
(comment) @comment
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
@@ -1,6 +1,15 @@
|
||||
((preproc_def (preproc_arg) @hlsl)
|
||||
(#lua-match? @hlsl "\n"))
|
||||
(preproc_function_def (preproc_arg) @hlsl)
|
||||
(preproc_call (preproc_arg) @hlsl)
|
||||
((preproc_def
|
||||
(preproc_arg) @injection.content)
|
||||
(#lua-match? @injection.content "\n")
|
||||
(#set! injection.language "hlsl"))
|
||||
|
||||
(comment) @comment
|
||||
(preproc_function_def
|
||||
(preproc_arg) @injection.content
|
||||
(#set! injection.language "hlsl"))
|
||||
|
||||
(preproc_call
|
||||
(preproc_arg) @injection.content
|
||||
(#set! injection.language "hlsl"))
|
||||
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
(comment) @comment
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
@@ -3,8 +3,10 @@
|
||||
(element
|
||||
(start_tag
|
||||
(tag_name) @_py_script)
|
||||
(text) @python
|
||||
(#any-of? @_py_script "py-script" "py-repl"))
|
||||
(text) @injection.content
|
||||
(#any-of? @_py_script "py-script" "py-repl")
|
||||
(#set! injection.language "python")
|
||||
(#set! injection.include-children))
|
||||
|
||||
(script_element
|
||||
(start_tag
|
||||
@@ -12,13 +14,17 @@
|
||||
(attribute_name) @_attr
|
||||
(quoted_attribute_value
|
||||
(attribute_value) @_type)))
|
||||
(raw_text) @python
|
||||
(raw_text) @injection.content
|
||||
(#eq? @_attr "type")
|
||||
; not adding type="py" here as it's handled by html_tags
|
||||
(#any-of? @_type "pyscript" "py-script"))
|
||||
(#any-of? @_type "pyscript" "py-script")
|
||||
(#set! injection.language "python")
|
||||
(#set! injection.include-children))
|
||||
|
||||
(element
|
||||
(start_tag
|
||||
(tag_name) @_py_config)
|
||||
(text) @toml
|
||||
(#eq? @_py_config "py-config"))
|
||||
(text) @injection.content
|
||||
(#eq? @_py_config "py-config")
|
||||
(#set! injection.language "toml")
|
||||
(#set! injection.include-children))
|
||||
|
||||
@@ -2,73 +2,84 @@
|
||||
; <style blocking> ...</style>
|
||||
; Add "lang" to predicate check so that vue/svelte can inherit this
|
||||
; without having this element being captured twice
|
||||
(
|
||||
(style_element
|
||||
((style_element
|
||||
(start_tag) @_no_type_lang
|
||||
(#not-lua-match? @_no_type_lang "%slang%s*=")
|
||||
(#not-lua-match? @_no_type_lang "%stype%s*=")
|
||||
(raw_text) @css))
|
||||
(raw_text) @injection.content)
|
||||
(#not-lua-match? @_no_type_lang "%slang%s*=")
|
||||
(#not-lua-match? @_no_type_lang "%stype%s*=")
|
||||
(#set! injection.language "css")
|
||||
(#set! injection.include-children))
|
||||
|
||||
(
|
||||
(style_element
|
||||
(start_tag
|
||||
(attribute
|
||||
(attribute_name) @_type
|
||||
(quoted_attribute_value (attribute_value) @_css)))
|
||||
(raw_text) @css)
|
||||
(#eq? @_type "type")
|
||||
(#eq? @_css "text/css")
|
||||
)
|
||||
((style_element
|
||||
(start_tag
|
||||
(attribute
|
||||
(attribute_name) @_type
|
||||
(quoted_attribute_value (attribute_value) @_css)))
|
||||
(raw_text) @injection.content)
|
||||
(#eq? @_type "type")
|
||||
(#eq? @_css "text/css")
|
||||
(#set! injection.language "css")
|
||||
(#set! injection.include-children))
|
||||
|
||||
; <script>...</script>
|
||||
; <script defer>...</script>
|
||||
(
|
||||
(script_element
|
||||
(start_tag) @_no_type_lang
|
||||
(#not-lua-match? @_no_type_lang "%slang%s*=")
|
||||
(#not-lua-match? @_no_type_lang "%stype%s*=")
|
||||
(raw_text) @javascript))
|
||||
((script_element
|
||||
(start_tag) @_no_type_lang
|
||||
(raw_text) @injection.content)
|
||||
(#not-lua-match? @_no_type_lang "%slang%s*=")
|
||||
(#not-lua-match? @_no_type_lang "%stype%s*=")
|
||||
(#set! injection.language "javascript")
|
||||
(#set! injection.include-children))
|
||||
|
||||
; <script type="mimetype-or-well-known-script-type">
|
||||
(script_element
|
||||
(start_tag
|
||||
((attribute
|
||||
(attribute_name) @_attr (#eq? @_attr "type")
|
||||
(quoted_attribute_value (attribute_value) @_type))))
|
||||
(raw_text) @content (#set-lang-from-mimetype! @_type))
|
||||
(start_tag
|
||||
((attribute
|
||||
(attribute_name) @_attr (#eq? @_attr "type")
|
||||
(quoted_attribute_value (attribute_value) @_type))))
|
||||
(raw_text) @injection.content (#set-lang-from-mimetype! @_type)
|
||||
(#set! injection.include-children))
|
||||
|
||||
; <a style="/* css */">
|
||||
((attribute
|
||||
(attribute_name) @_attr
|
||||
(quoted_attribute_value (attribute_value) @css))
|
||||
(#eq? @_attr "style"))
|
||||
(quoted_attribute_value (attribute_value) @injection.content))
|
||||
(#eq? @_attr "style")
|
||||
(#set! injection.language "css")
|
||||
(#set! injection.include-children))
|
||||
|
||||
; lit-html style template interpolation
|
||||
; <a @click=${e => console.log(e)}>
|
||||
; <a @click="${e => console.log(e)}">
|
||||
((attribute
|
||||
(quoted_attribute_value (attribute_value) @javascript))
|
||||
(#lua-match? @javascript "%${")
|
||||
(#offset! @javascript 0 2 0 -1))
|
||||
((attribute
|
||||
(attribute_value) @javascript)
|
||||
(#lua-match? @javascript "%${")
|
||||
(#offset! @javascript 0 2 0 -2))
|
||||
(quoted_attribute_value (attribute_value) @injection.content))
|
||||
(#lua-match? @injection.content "%${")
|
||||
(#offset! @injection.content 0 2 0 -1)
|
||||
(#set! injection.language "javascript")
|
||||
(#set! injection.include-children))
|
||||
|
||||
(comment) @comment
|
||||
((attribute
|
||||
(attribute_value) @injection.content)
|
||||
(#lua-match? @injection.content "%${")
|
||||
(#offset! @injection.content 0 2 0 -2)
|
||||
(#set! injection.language "javascript")
|
||||
(#set! injection.include-children))
|
||||
|
||||
; <input pattern="[0-9]"> or <input pattern=[0-9]>
|
||||
(element (_
|
||||
(tag_name) @_tagname (#eq? @_tagname "input")
|
||||
((attribute
|
||||
(attribute_name) @_attr [
|
||||
(quoted_attribute_value (attribute_value) @regex)
|
||||
(attribute_value) @regex
|
||||
(quoted_attribute_value (attribute_value) @injection.content)
|
||||
(attribute_value) @injection.content
|
||||
] (#eq? @_attr "pattern")))
|
||||
))
|
||||
(#set! injection.language "regex")
|
||||
(#set! injection.include-children)))
|
||||
|
||||
; <input type="checkbox" onchange="this.closest('form').elements.output.value = this.checked">
|
||||
(attribute
|
||||
(attribute_name) @_name
|
||||
(#lua-match? @_name "^on[a-z]+$")
|
||||
(quoted_attribute_value (attribute_value) @javascript))
|
||||
(quoted_attribute_value (attribute_value) @injection.content)
|
||||
(#set! injection.language "javascript")
|
||||
(#set! injection.include-children))
|
||||
|
||||
@@ -1 +1,3 @@
|
||||
(content) @html @combined
|
||||
((content) @injection.content
|
||||
(#set! injection.language "html")
|
||||
(#set! injection.combined))
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
(comment) @comment
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
(json_body) @json
|
||||
((json_body) @injection.content
|
||||
(#set! injection.language "json"))
|
||||
|
||||
; (xml_body) @xml
|
||||
; ((xml_body) @injection.content
|
||||
; (#set! injection.language "xml"))
|
||||
|
||||
; (graphql_body) @graphql Not used as of now..
|
||||
; ((graphql_body) @injection.content
|
||||
; (#set! injection.language "graphql")) ; Not used as of now..
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
; injections.scm
|
||||
(json_value) @json
|
||||
(xml) @html
|
||||
((json_value) @injection.content
|
||||
(#set! injection.language "json"))
|
||||
|
||||
((xml) @injection.content
|
||||
(#set! injection.language "html"))
|
||||
|
||||
(multiline_string
|
||||
(multiline_string_type) @language
|
||||
(multiline_string_content) @content)
|
||||
(multiline_string_type) @_lang
|
||||
(multiline_string_content) @injection.content
|
||||
(#inject-language! @_lang))
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
(comment) @comment
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
[
|
||||
([
|
||||
(block_comment)
|
||||
(line_comment)
|
||||
] @comment
|
||||
] @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
(comment) @comment
|
||||
((comment) @injection.content (#set! injection.language "comment"))
|
||||
|
||||
; test(val)
|
||||
(query
|
||||
@@ -12,7 +12,10 @@
|
||||
"splits"
|
||||
"sub"
|
||||
"gsub"))
|
||||
(args . (query (string) @regex)))
|
||||
(args .
|
||||
(query
|
||||
(string) @injection.content
|
||||
(#set! injection.language "regex"))))
|
||||
|
||||
|
||||
; test(regex; flags)
|
||||
@@ -28,4 +31,6 @@
|
||||
"sub"
|
||||
"gsub"))
|
||||
(args . (args
|
||||
(query (string) @regex))))
|
||||
(query
|
||||
(string) @injection.content
|
||||
(#set! injection.language "regex")))))
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
(comment) @comment
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
(comment) @comment
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
(jsx_opening_element
|
||||
(identifier) @_name (#eq? @_name "style")
|
||||
(jsx_attribute) @_attr (#eq? @_attr "jsx"))
|
||||
(jsx_expression (template_string) @css
|
||||
(#offset! @css 0 1 0 -1))
|
||||
)
|
||||
(jsx_expression
|
||||
((template_string) @injection.content
|
||||
(#set! injection.language "css"))
|
||||
(#offset! @injection.content 0 1 0 -1)))
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
;; Inject markdown in docstrings
|
||||
((string_literal) @markdown
|
||||
((string_literal) @injection.content
|
||||
. [
|
||||
(module_definition)
|
||||
(abstract_definition)
|
||||
@@ -9,15 +9,18 @@
|
||||
(assignment)
|
||||
(const_statement)
|
||||
]
|
||||
(#lua-match? @markdown "^\"\"\"")
|
||||
(#offset! @markdown 0 3 0 -3))
|
||||
(#lua-match? @injection.content "^\"\"\"")
|
||||
(#set! injection.language "markdown")
|
||||
(#offset! @injection.content 0 3 0 -3))
|
||||
|
||||
[
|
||||
([
|
||||
(line_comment)
|
||||
(block_comment)
|
||||
] @comment
|
||||
] @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
((prefixed_string_literal
|
||||
prefix: (identifier) @_prefix) @regex
|
||||
prefix: (identifier) @_prefix) @injection.content
|
||||
(#eq? @_prefix "r")
|
||||
(#offset! @regex 0 2 0 -1))
|
||||
(#set! injection.language "regex")
|
||||
(#offset! @injection.content 0 2 0 -1))
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
[
|
||||
([
|
||||
(single_line_comment)
|
||||
(multi_line_comment)
|
||||
] @comment
|
||||
] @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
@@ -1,35 +1,36 @@
|
||||
[
|
||||
([
|
||||
(line_comment)
|
||||
(multiline_comment)
|
||||
] @comment
|
||||
] @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
; There are 3 ways to define a regex
|
||||
; - "[abc]?".toRegex()
|
||||
(call_expression
|
||||
(navigation_expression
|
||||
((string_literal) @regex)
|
||||
(navigation_suffix
|
||||
((simple_identifier) @_function
|
||||
(#eq? @_function "toRegex")))))
|
||||
(navigation_expression
|
||||
((string_literal) @injection.content (#set! injection.language "regex"))
|
||||
(navigation_suffix
|
||||
((simple_identifier) @_function
|
||||
(#eq? @_function "toRegex")))))
|
||||
|
||||
; - Regex("[abc]?")
|
||||
(call_expression
|
||||
((simple_identifier) @_function
|
||||
(#eq? @_function "Regex"))
|
||||
(call_suffix
|
||||
(value_arguments
|
||||
(value_argument
|
||||
(string_literal) @regex))))
|
||||
((simple_identifier) @_function
|
||||
(#eq? @_function "Regex"))
|
||||
(call_suffix
|
||||
(value_arguments
|
||||
(value_argument
|
||||
(string_literal) @injection.content (#set! injection.language "regex")))))
|
||||
|
||||
; - Regex.fromLiteral("[abc]?")
|
||||
(call_expression
|
||||
(navigation_expression
|
||||
((simple_identifier) @_class
|
||||
(#eq? @_class "Regex"))
|
||||
(navigation_suffix
|
||||
((simple_identifier) @_function
|
||||
(#eq? @_function "fromLiteral"))))
|
||||
(call_suffix
|
||||
(value_arguments
|
||||
(value_argument
|
||||
(string_literal) @regex))))
|
||||
(navigation_expression
|
||||
((simple_identifier) @_class
|
||||
(#eq? @_class "Regex"))
|
||||
(navigation_suffix
|
||||
((simple_identifier) @_function
|
||||
(#eq? @_function "fromLiteral"))))
|
||||
(call_suffix
|
||||
(value_arguments
|
||||
(value_argument
|
||||
(string_literal) @injection.content (#set! injection.language "regex")))))
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
[
|
||||
(normal_action)
|
||||
(failible_action)
|
||||
] @rust
|
||||
([
|
||||
(normal_action)
|
||||
(failible_action)
|
||||
] @injection.content
|
||||
(#set! injection.language "rust"))
|
||||
|
||||
(use) @rust
|
||||
((use) @injection.content (#set! injection.language "rust"))
|
||||
|
||||
((regex_literal) @regex
|
||||
(#offset! @regex 0 2 0 -1))
|
||||
((regex_literal) @injection.content
|
||||
(#set! injection.language "regex")
|
||||
(#offset! @injection.content 0 2 0 -1))
|
||||
|
||||
@@ -1,22 +1,25 @@
|
||||
[
|
||||
(line_comment)
|
||||
(block_comment)
|
||||
(comment_environment)
|
||||
] @comment
|
||||
([
|
||||
(line_comment)
|
||||
(block_comment)
|
||||
(comment_environment)
|
||||
] @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
(pycode_environment
|
||||
code: (source_code) @python
|
||||
)
|
||||
code:
|
||||
(source_code) @injection.content
|
||||
(#set! injection.language "python"))
|
||||
|
||||
(minted_environment
|
||||
(begin
|
||||
language: (curly_group_text
|
||||
(text) @language))
|
||||
(source_code) @content)
|
||||
(text) @injection.language))
|
||||
(source_code) @injection.content)
|
||||
|
||||
((generic_environment
|
||||
(begin
|
||||
name: (curly_group_text
|
||||
(text) @_env))) @c
|
||||
(text) @_env))) @injection.content
|
||||
(#set! injection.language "c")
|
||||
(#any-of? @_env "asy" "asydef"))
|
||||
|
||||
|
||||
@@ -1,2 +1,5 @@
|
||||
(comment) @comment
|
||||
(note) @comment
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
((note) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
@@ -243,5 +243,7 @@
|
||||
|
||||
(string) @string
|
||||
|
||||
(escape_sequence) @string.escape
|
||||
|
||||
;; Error
|
||||
(ERROR) @error
|
||||
|
||||
@@ -3,57 +3,65 @@
|
||||
(identifier) @_cdef_identifier
|
||||
(_ _ (identifier) @_cdef_identifier)
|
||||
]
|
||||
arguments: (arguments (string content: _ @c)))
|
||||
arguments:
|
||||
(arguments
|
||||
(string content: _ @injection.content)))
|
||||
(#set! injection.language "c")
|
||||
(#eq? @_cdef_identifier "cdef"))
|
||||
|
||||
((function_call
|
||||
name: (_) @_vimcmd_identifier
|
||||
arguments: (arguments . (string content: _ @vim)))
|
||||
(#any-of? @_vimcmd_identifier "vim.cmd" "vim.api.nvim_command" "vim.api.nvim_exec" "vim.api.nvim_exec2"))
|
||||
arguments: (arguments (string content: _ @injection.content)))
|
||||
(#set! injection.language "vim")
|
||||
(#any-of? @_vimcmd_identifier "vim.cmd" "vim.api.nvim_command" "vim.api.nvim_command" "vim.api.nvim_exec2"))
|
||||
|
||||
((function_call
|
||||
name: (_) @_vimcmd_identifier
|
||||
arguments: (arguments (string content: _ @query) .))
|
||||
(#any-of? @_vimcmd_identifier "vim.treesitter.query.set" "vim.treesitter.query.parse_query" "vim.treesitter.query.parse"))
|
||||
arguments: (arguments (string content: _ @injection.content) .))
|
||||
(#set! injection.language "query")
|
||||
(#any-of? @_vimcmd_identifier "vim.treesitter.query.set" "vim.treesitter.query.parse"))
|
||||
|
||||
; vim.rcprequest(123, "nvim_exec_lua", "return vim.api.nvim_buf_get_lines(0, 0, -1, false)", false)
|
||||
((function_call
|
||||
name: (_) @_vimcmd_identifier
|
||||
arguments: (arguments . (_) . (string content: _ @_method) . (string content: _ @lua)))
|
||||
arguments: (arguments . (_) . (string content: _ @_method) . (string content: _ @injection.content)))
|
||||
(#any-of? @_vimcmd_identifier "vim.rpcrequest" "vim.rpcnotify")
|
||||
(#eq? @_method "nvim_exec_lua"))
|
||||
(#eq? @_method "nvim_exec_lua")
|
||||
(#set! injection.language "lua"))
|
||||
|
||||
; highlight string as query if starts with `;; query`
|
||||
(string content: _ @query (#lua-match? @query "^%s*;+%s?query"))
|
||||
;; highlight string as query if starts with `;; query`
|
||||
(string content: _ @injection.content
|
||||
(#lua-match? @injection.content "^%s*;+%s?query")
|
||||
(#set! injection.language "query"))
|
||||
|
||||
((comment) @luadoc
|
||||
(#lua-match? @luadoc "[-][-][-][%s]*@")
|
||||
(#offset! @luadoc 0 3 0 0))
|
||||
((comment) @injection.content
|
||||
(#lua-match? @injection.content "[-][-][-][%s]*@")
|
||||
(#set! injection.language "luadoc")
|
||||
(#offset! @injection.content 0 3 0 0))
|
||||
|
||||
; string.match("123", "%d+")
|
||||
(function_call
|
||||
(dot_index_expression
|
||||
field: (identifier) @_method
|
||||
(#any-of? @_method "find" "match"))
|
||||
arguments: (arguments (_) . (string content: _ @luap)))
|
||||
arguments: (arguments (_) . (string content: _ @injection.content (#set! injection.language "luap"))))
|
||||
|
||||
(function_call
|
||||
(dot_index_expression
|
||||
field: (identifier) @_method
|
||||
(#any-of? @_method "gmatch" "gsub"))
|
||||
arguments: (arguments (_) (string content: _ @luap)))
|
||||
arguments: (arguments (_) (string content: _ @injection.content (#set! injection.language "luap"))))
|
||||
|
||||
; ("123"):match("%d+")
|
||||
(function_call
|
||||
(method_index_expression
|
||||
method: (identifier) @_method
|
||||
(#any-of? @_method "find" "match"))
|
||||
arguments: (arguments . (string content: _ @luap)))
|
||||
arguments: (arguments . (string content: _ @injection.content (#set! injection.language "luap"))))
|
||||
|
||||
(function_call
|
||||
(method_index_expression
|
||||
method: (identifier) @_method
|
||||
(#any-of? @_method "gmatch" "gsub"))
|
||||
arguments: (arguments (string content: _ @luap)))
|
||||
arguments: (arguments (string content: _ @injection.content (#set! injection.language "luap"))))
|
||||
|
||||
(comment) @comment
|
||||
((comment) @injection.content (#set! injection.language "comment"))
|
||||
|
||||
@@ -3,37 +3,44 @@
|
||||
(identifier) @_cdef_identifier
|
||||
(_ _ (identifier) @_cdef_identifier)
|
||||
]
|
||||
arguments: (arguments (string content: _ @c)))
|
||||
(#eq? @_cdef_identifier "cdef"))
|
||||
arguments: (arguments (string content: _ @injection.content)))
|
||||
(#eq? @_cdef_identifier "cdef")
|
||||
(#set! injection.language "c"))
|
||||
|
||||
((comment) @luadoc
|
||||
(#lua-match? @luadoc "[-][-][-][%s]*@")
|
||||
(#offset! @luadoc 0 3 0 0))
|
||||
((comment) @injection.content
|
||||
(#lua-match? @injection.content "[-][-][-][%s]*@")
|
||||
(#offset! @injection.content 0 3 0 0)
|
||||
(#set! injection.language "luadoc"))
|
||||
|
||||
; string.match("123", "%d+")
|
||||
(function_call
|
||||
(dot_index_expression
|
||||
field: (identifier) @_method
|
||||
(#any-of? @_method "find" "format" "match"))
|
||||
arguments: (arguments (_) . (string content: _ @luap)))
|
||||
arguments: (arguments (_) . (string content: _ @injection.content))
|
||||
(#set! injection.language "luap"))
|
||||
|
||||
(function_call
|
||||
(dot_index_expression
|
||||
field: (identifier) @_method
|
||||
(#any-of? @_method "gmatch" "gsub"))
|
||||
arguments: (arguments (_) (string content: _ @luap)))
|
||||
arguments: (arguments (_) (string content: _ @injection.content))
|
||||
(#set! injection.language "luap"))
|
||||
|
||||
; ("123"):match("%d+")
|
||||
(function_call
|
||||
(method_index_expression
|
||||
method: (identifier) @_method
|
||||
(#any-of? @_method "find" "format" "match"))
|
||||
arguments: (arguments . (string content: _ @luap)))
|
||||
arguments: (arguments . (string content: _ @injection.content))
|
||||
(#set! injection.language "luap"))
|
||||
|
||||
(function_call
|
||||
(method_index_expression
|
||||
method: (identifier) @_method
|
||||
(#any-of? @_method "gmatch" "gsub"))
|
||||
arguments: (arguments (string content: _ @luap)))
|
||||
arguments: (arguments (string content: _ @injection.content))
|
||||
(#set! injection.language "luap"))
|
||||
|
||||
(comment) @comment
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
(comment) @comment
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
(comment) @comment
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
(shell_text) @bash
|
||||
(shell_command) @bash
|
||||
((shell_text) @injection.content
|
||||
(#set! injection.language "bash"))
|
||||
((shell_command) @injection.content
|
||||
(#set! injection.language "bash"))
|
||||
|
||||
@@ -1,17 +1,26 @@
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @_lang)
|
||||
(code_fence_content)
|
||||
@content
|
||||
(#set-lang-from-info-string! @_lang)
|
||||
(#exclude_children! @content))
|
||||
(code_fence_content) @injection.content
|
||||
(#set-lang-from-info-string! @_lang))
|
||||
|
||||
((html_block) @html @combined)
|
||||
((html_block) @injection.content
|
||||
(#set! injection.language "html")
|
||||
(#set! injection.combined)
|
||||
(#set! injection.include-children))
|
||||
|
||||
((minus_metadata) @yaml (#offset! @yaml 1 0 -1 0))
|
||||
((plus_metadata) @toml (#offset! @toml 1 0 -1 0))
|
||||
((minus_metadata) @injection.content
|
||||
(#set! injection.language "yaml")
|
||||
(#offset! @injection.content 1 0 -1 0)
|
||||
(#set! injection.include-children))
|
||||
|
||||
((plus_metadata) @injection.content
|
||||
(#set! injection.language "toml")
|
||||
(#offset! @injection.content 1 0 -1 0)
|
||||
(#set! injection.include-children))
|
||||
|
||||
([
|
||||
(inline)
|
||||
(pipe_table_cell)
|
||||
] @markdown_inline (#exclude_children! @markdown_inline))
|
||||
] @injection.content
|
||||
(#set! injection.language "markdown_inline"))
|
||||
|
||||
@@ -1,2 +1,8 @@
|
||||
((html_tag) @html @combined)
|
||||
((latex_block) @latex)
|
||||
((html_tag) @injection.content
|
||||
(#set! injection.language "html")
|
||||
(#set! injection.combined)
|
||||
(#set! injection.include-children))
|
||||
|
||||
((latex_block) @injection.content
|
||||
(#set! injection.language "latex")
|
||||
(#set! injection.include-children))
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
(comment) @comment
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
(ocaml) @ocaml
|
||||
((ocaml) @injection.content
|
||||
(#set! injection.language "ocaml"))
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
(comment) @comment
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
@@ -1,19 +1,24 @@
|
||||
(comment) @comment
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
(apply_expression
|
||||
function: (_) @_func
|
||||
argument: [
|
||||
(string_expression (string_fragment) @regex)
|
||||
(indented_string_expression (string_fragment) @regex)
|
||||
(string_expression
|
||||
((string_fragment) @injection.content (#set! injection.language "regex")))
|
||||
(indented_string_expression
|
||||
((string_fragment) @injection.content (#set! injection.language "regex")))
|
||||
]
|
||||
(#match? @_func "(^|\\.)match$"))
|
||||
@combined
|
||||
(#match? @_func "(^|\\.)match$")
|
||||
(#set! injection.combined))
|
||||
|
||||
(binding
|
||||
attrpath: (attrpath (identifier) @_path)
|
||||
expression: [
|
||||
(string_expression (string_fragment) @bash)
|
||||
(indented_string_expression (string_fragment) @bash)
|
||||
(string_expression
|
||||
((string_fragment) @injection.content (#set! injection.language "bash")))
|
||||
(indented_string_expression
|
||||
((string_fragment) @injection.content (#set! injection.language "bash")))
|
||||
]
|
||||
(#match? @_path "(^\\w+(Phase|Hook)|(pre|post)[A-Z]\\w+|script)$"))
|
||||
|
||||
@@ -22,87 +27,105 @@
|
||||
argument: (_ (_)* (_ (_)* (binding
|
||||
attrpath: (attrpath (identifier) @_path)
|
||||
expression: [
|
||||
(string_expression (string_fragment) @bash)
|
||||
(indented_string_expression (string_fragment) @bash)
|
||||
(string_expression
|
||||
((string_fragment) @injection.content (#set! injection.language "bash")))
|
||||
(indented_string_expression
|
||||
((string_fragment) @injection.content (#set! injection.language "bash")))
|
||||
])))
|
||||
(#match? @_func "(^|\\.)writeShellApplication$")
|
||||
(#match? @_path "^text$"))
|
||||
@combined
|
||||
(#match? @_path "^text$")
|
||||
(#set! injection.combined))
|
||||
|
||||
(apply_expression
|
||||
function: (apply_expression
|
||||
function: (apply_expression function: (_) @_func))
|
||||
argument: [
|
||||
(string_expression (string_fragment) @bash)
|
||||
(indented_string_expression (string_fragment) @bash)
|
||||
(string_expression
|
||||
((string_fragment) @injection.content (#set! injection.language "bash")))
|
||||
(indented_string_expression
|
||||
((string_fragment) @injection.content (#set! injection.language "bash")))
|
||||
]
|
||||
(#match? @_func "(^|\\.)runCommand((No)?CC)?(Local)?$"))
|
||||
@combined
|
||||
(#match? @_func "(^|\\.)runCommand((No)?CC)?(Local)?$")
|
||||
(#set! injection.combined))
|
||||
|
||||
((apply_expression
|
||||
function: (apply_expression function: (_) @_func)
|
||||
argument: [
|
||||
(string_expression (string_fragment) @bash)
|
||||
(indented_string_expression (string_fragment) @bash)
|
||||
(string_expression
|
||||
((string_fragment) @injection.content (#set! injection.language "bash")))
|
||||
(indented_string_expression
|
||||
((string_fragment) @injection.content (#set! injection.language "bash")))
|
||||
])
|
||||
(#match? @_func "(^|\\.)write(Bash|Dash|ShellScript)(Bin)?$"))
|
||||
@combined
|
||||
(#match? @_func "(^|\\.)write(Bash|Dash|ShellScript)(Bin)?$")
|
||||
(#set! injection.combined))
|
||||
|
||||
((apply_expression
|
||||
function: (apply_expression function: (_) @_func)
|
||||
argument: [
|
||||
(string_expression (string_fragment) @fish)
|
||||
(indented_string_expression (string_fragment) @fish)
|
||||
(string_expression
|
||||
((string_fragment) @injection.content (#set! injection.language "fish")))
|
||||
(indented_string_expression
|
||||
((string_fragment) @injection.content (#set! injection.language "fish")))
|
||||
])
|
||||
(#match? @_func "(^|\\.)writeFish(Bin)?$"))
|
||||
@combined
|
||||
(#match? @_func "(^|\\.)writeFish(Bin)?$")
|
||||
(#set! injection.combined))
|
||||
|
||||
((apply_expression
|
||||
function: (apply_expression
|
||||
function: (apply_expression function: (_) @_func))
|
||||
argument: [
|
||||
(string_expression (string_fragment) @haskell)
|
||||
(indented_string_expression (string_fragment) @haskell)
|
||||
(string_expression
|
||||
((string_fragment) @injection.content (#set! injection.language "haskell")))
|
||||
(indented_string_expression
|
||||
((string_fragment) @injection.content (#set! injection.language "haskell")))
|
||||
])
|
||||
(#match? @_func "(^|\\.)writeHaskell(Bin)?$"))
|
||||
@combined
|
||||
(#match? @_func "(^|\\.)writeHaskell(Bin)?$")
|
||||
(#set! injection.combined))
|
||||
|
||||
((apply_expression
|
||||
function: (apply_expression
|
||||
function: (apply_expression function: (_) @_func))
|
||||
argument: [
|
||||
(string_expression (string_fragment) @javascript)
|
||||
(indented_string_expression (string_fragment) @javascript)
|
||||
(string_expression
|
||||
((string_fragment) @injection.content (#set! injection.language "javascript")))
|
||||
(indented_string_expression
|
||||
((string_fragment) @injection.content (#set! injection.language "javascript")))
|
||||
])
|
||||
(#match? @_func "(^|\\.)writeJS(Bin)?$"))
|
||||
@combined
|
||||
(#match? @_func "(^|\\.)writeJS(Bin)?$")
|
||||
(#set! injection.combined))
|
||||
|
||||
((apply_expression
|
||||
function: (apply_expression
|
||||
function: (apply_expression function: (_) @_func))
|
||||
argument: [
|
||||
(string_expression (string_fragment) @perl)
|
||||
(indented_string_expression (string_fragment) @perl)
|
||||
(string_expression
|
||||
((string_fragment) @injection.content (#set! injection.language "perl")))
|
||||
(indented_string_expression
|
||||
((string_fragment) @injection.content (#set! injection.language "perl")))
|
||||
])
|
||||
(#match? @_func "(^|\\.)writePerl(Bin)?$"))
|
||||
@combined
|
||||
(#match? @_func "(^|\\.)writePerl(Bin)?$")
|
||||
(#set! injection.combined))
|
||||
|
||||
((apply_expression
|
||||
function: (apply_expression
|
||||
function: (apply_expression function: (_) @_func))
|
||||
argument: [
|
||||
(string_expression (string_fragment) @python)
|
||||
(indented_string_expression (string_fragment) @python)
|
||||
(string_expression
|
||||
((string_fragment) @injection.content (#set! injection.language "python")))
|
||||
(indented_string_expression
|
||||
((string_fragment) @injection.content (#set! injection.language "python")))
|
||||
])
|
||||
(#match? @_func "(^|\\.)write(PyPy|Python)[23](Bin)?$"))
|
||||
@combined
|
||||
(#match? @_func "(^|\\.)write(PyPy|Python)[23](Bin)?$")
|
||||
(#set! injection.combined))
|
||||
|
||||
((apply_expression
|
||||
function: (apply_expression
|
||||
function: (apply_expression function: (_) @_func))
|
||||
argument: [
|
||||
(string_expression (string_fragment) @rust)
|
||||
(indented_string_expression (string_fragment) @rust)
|
||||
(string_expression
|
||||
((string_fragment) @injection.content (#set! injection.language "rust")))
|
||||
(indented_string_expression
|
||||
((string_fragment) @injection.content (#set! injection.language "rust")))
|
||||
])
|
||||
(#match? @_func "(^|\\.)writeRust(Bin)?$"))
|
||||
@combined
|
||||
(#match? @_func "(^|\\.)writeRust(Bin)?$")
|
||||
(#set! injection.combined))
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
(comment) @comment
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
(ocaml) @ocaml
|
||||
((ocaml) @injection.content
|
||||
(#set! injection.language "ocaml"))
|
||||
|
||||
(comment) @comment
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
(comment) @comment
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
(comment) @comment
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
; There is no parser for assembly language yet. Add an injection here when we
|
||||
; have a parser.
|
||||
; (asmBody) @asm
|
||||
; ((asmBody) @injection.content
|
||||
; (#set! injection.language "asm"))
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
(comment) @comment
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
(comments) @comment
|
||||
((comments) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
@@ -1,20 +1,34 @@
|
||||
(text) @html @combined
|
||||
((text) @injection.content
|
||||
(#set! injection.language "html")
|
||||
(#set! injection.combined))
|
||||
|
||||
(comment) @phpdoc
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "phpdoc"))
|
||||
|
||||
;; regex
|
||||
|
||||
((function_call_expression
|
||||
function: (_) @_preg_func_identifier
|
||||
arguments: (arguments . (argument (_ (string_value) @regex))))
|
||||
arguments:
|
||||
(arguments .
|
||||
(argument
|
||||
(_ (string_value) @injection.content))))
|
||||
(#set! injection.language "regex")
|
||||
(#lua-match? @_preg_func_identifier "^preg_"))
|
||||
|
||||
;; bash
|
||||
|
||||
((function_call_expression
|
||||
function: (_) @_shell_func_identifier
|
||||
arguments: (arguments . (argument (_ (string_value) @bash))))
|
||||
arguments:
|
||||
(arguments .
|
||||
(argument
|
||||
(_ (string_value) @injection.content))))
|
||||
(#set! injection.language "bash")
|
||||
(#any-of? @_shell_func_identifier "shell_exec" "escapeshellarg"
|
||||
"escapeshellcmd" "exec" "passthru" "proc_open" "shell_exec" "system"))
|
||||
|
||||
((expression_statement (shell_command_expression (string_value) @bash)))
|
||||
(expression_statement
|
||||
(shell_command_expression
|
||||
(string_value) @injection.content)
|
||||
(#set! injection.language "bash"))
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
[ (line_comment) (block_comment) ] @comment
|
||||
([
|
||||
(line_comment)
|
||||
(block_comment)
|
||||
] @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
((code_block
|
||||
(code_block_language) @_language
|
||||
(code_block_body) @c)
|
||||
(#eq? @_language "c-sdk"))
|
||||
(code_block_body) @injection.content)
|
||||
(#eq? @_language "c-sdk")
|
||||
(#set! injection.language "c"))
|
||||
|
||||
(code_block
|
||||
(code_block_language) @language
|
||||
(code_block_body) @content)
|
||||
(code_block_language) @injection.language
|
||||
(code_block_body) @injection.content)
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
(comment) @comment
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
(comment) @comment
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
[
|
||||
([
|
||||
(line_comment)
|
||||
(block_comment)
|
||||
] @comment
|
||||
] @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
@@ -1 +1,3 @@
|
||||
((label_value) @regex (#offset! @regex 0 1 0 -1))
|
||||
((label_value) @injection.content
|
||||
(#set! injection.language "regex")
|
||||
(#offset! @injection.content 0 1 0 -1))
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
(
|
||||
(s_string) @sql
|
||||
(#offset! @sql 0 2 0 -1)
|
||||
)
|
||||
((s_string) @injection.content
|
||||
(#set! injection.language "sql")
|
||||
(#offset! @injection.content 0 2 0 -1))
|
||||
|
||||
(from_text
|
||||
(keyword_from_text)
|
||||
(keyword_json)
|
||||
(literal) @json
|
||||
(#offset! @json 0 3 0 -3)
|
||||
)
|
||||
(literal) @injection.content
|
||||
(#set! injection.language "json")
|
||||
(#offset! @injection.content 0 3 0 -3))
|
||||
|
||||
(comment) @comment
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
(javascript) @javascript
|
||||
((javascript) @injection.content
|
||||
(#set! injection.language "javascript"))
|
||||
|
||||
(
|
||||
(attribute_name) @_attribute_name
|
||||
(quoted_attribute_value (attribute_value ) @javascript)
|
||||
(#match? @_attribute_name "^(:|v-bind|v-|\\@)")
|
||||
)
|
||||
((attribute_name) @_attribute_name
|
||||
(quoted_attribute_value
|
||||
(attribute_value) @injection.content
|
||||
(#set! injection.language "javascript"))
|
||||
(#match? @_attribute_name "^(:|v-bind|v-|\\@)"))
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
((regex) @regex
|
||||
(#offset! @regex 0 1 0 -1))
|
||||
((regex) @injection.content
|
||||
(#set! injection.language "regex")
|
||||
(#offset! @injection.content 0 1 0 -1))
|
||||
|
||||
(comment) @comment
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
((call
|
||||
function: (attribute
|
||||
object: (identifier) @_re)
|
||||
arguments: (argument_list (string) @regex))
|
||||
arguments: (argument_list (string) @injection.content))
|
||||
(#eq? @_re "re")
|
||||
(#lua-match? @regex "^r.*"))
|
||||
(#lua-match? @injection.content "^r.*")
|
||||
(#set! injection.language "regex"))
|
||||
|
||||
(comment) @comment
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
[
|
||||
([
|
||||
(line_comment)
|
||||
(block_comment)
|
||||
(qldoc)
|
||||
] @comment
|
||||
] @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
(comment) @comment
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
((predicate
|
||||
name: (identifier) @_name
|
||||
parameters: (parameters (string) @regex))
|
||||
parameters: (parameters (string) @injection.content))
|
||||
(#match? @_name "^#?(not-)?(match|vim-match)$")
|
||||
(#offset! @regex 0 1 0 -1))
|
||||
(#set! injection.language "regex")
|
||||
(#offset! @injection.content 0 1 0 -1))
|
||||
|
||||
((predicate
|
||||
name: (identifier) @_name
|
||||
parameters: (parameters (string) @luap))
|
||||
parameters: (parameters (string) @injection.content))
|
||||
(#match? @_name "^#?(not-)?lua-match$")
|
||||
(#offset! @luap 0 1 0 -1))
|
||||
(#set! injection.language "luap")
|
||||
(#offset! @injection.content 0 1 0 -1))
|
||||
|
||||
(comment) @comment
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user