Skip to content

Commit

Permalink
Set include-children on NeoVim too
Browse files Browse the repository at this point in the history
Apparently this is supported, just not documented.
  • Loading branch information
tgross35 committed Mar 11, 2024
1 parent 4c4c63e commit 9d42286
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 22 deletions.
6 changes: 2 additions & 4 deletions build-flavored-queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@
"injections.scm": [
"injection.combined",
"injection.language",
"injection.include-children",
]
}

Expand All @@ -202,8 +203,6 @@
# Changes to textobject queries
(r"(@[\w.]+.)inside", r"\1inner"),
(r"(@[\w.]+.)around", r"\1outer"),
# nvim does not have `injection.include-children`
(r"\n?\s*\(\s*#set!\s*injection\.include-children\s*\)", "", re.MULTILINE),
# nvim uses `var` rather than `variable`
(r"(@[\w.]+)\.variable", r"\1.var"),
]
Expand Down Expand Up @@ -320,6 +319,7 @@
"injections.scm": [
"injection.combined",
"injection.language",
"injection.include-children",
]
}

Expand All @@ -337,8 +337,6 @@
# Changes to textobject queries
(r"(@[\w.]+).inside", "\1.inner"),
(r"(@[\w.]+).around", "\1.outer"),
# nvim does not have `injection.include-children`
(r"\s*\n?\s*\(\s*#set!\s*injection\.include-children\s*\)", "", re.MULTILINE),
# nvim uses `var` rather than `variable`
(r"(@[\w.]+)\.variable", r"\1.var"),
# nothing more specific than reference
Expand Down
3 changes: 2 additions & 1 deletion queries-flavored/helix/injections.scm
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
(#set! injection.language "comment"))

; Highlight the RHS of `=~` as regex
((regex_literal (_) @injection.content)
((regex_literal
(_) @injection.content)
(#set! injection.language "regex"))

; ================ Global defaults ================
Expand Down
3 changes: 2 additions & 1 deletion queries-flavored/lapce/injections.scm
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
(#set! injection.language "comment"))

; Highlight the RHS of `=~` as regex
((regex_literal (_) @injection.content)
((regex_literal
(_) @injection.content)
(#set! injection.language "regex"))

; ================ Global defaults ================
Expand Down
20 changes: 13 additions & 7 deletions queries-flavored/nvim-next/injections.scm
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@
(#set! injection.language "comment"))

; Highlight the RHS of `=~` as regex
((regex_literal (_) @injection.content)
((regex_literal
(_) @injection.content)
(#set! injection.language "regex"))

; ================ Global defaults ================

; Default everything to be bash
(recipe_body
(#set! injection.language "bash")) @injection.content
(#set! injection.language "bash")
(#set! injection.include-children)) @injection.content

(external_command
(command_body) @injection.content
Expand Down Expand Up @@ -46,7 +48,7 @@
(#set! injection.language "powershell"))
[
(recipe
(recipe_body) @injection.content)
(recipe_body (#set! injection.include-children)) @injection.content)

(assignment
(expression
Expand All @@ -60,7 +62,8 @@
(#not-match? @injection.language ".*(powershell|pwsh|cmd).*"))
[
(recipe
(recipe_body) @injection.content)
(recipe_body
(#set! injection.include-children)) @injection.content)

(assignment
(expression
Expand All @@ -75,7 +78,8 @@
(recipe_body ;
(shebang ;
(language) @injection.language) ;
(#not-any-of? @injection.language "python3" "nodejs" "node")) @injection.content
(#not-any-of? @injection.language "python3" "nodejs" "node")
(#set! injection.include-children)) @injection.content

; Transform some known executables

Expand All @@ -84,11 +88,13 @@
(shebang
(language) @_lang)
(#eq? @_lang "python3")
(#set! injection.language "python")) @injection.content
(#set! injection.language "python")
(#set! injection.include-children)) @injection.content

; node/nodejs -> javascript
(recipe_body
(shebang
(language) @_lang)
(#any-of? @_lang "node" "nodejs")
(#set! injection.language "javascript")) @injection.content
(#set! injection.language "javascript")
(#set! injection.include-children)) @injection.content
3 changes: 2 additions & 1 deletion queries-flavored/zed/injections.scm
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
(#set! injection.language "comment"))

; Highlight the RHS of `=~` as regex
((regex_literal (_) @injection.content)
((regex_literal
(_) @injection.content)
(#set! injection.language "regex"))

; ================ Global defaults ================
Expand Down
3 changes: 2 additions & 1 deletion queries-src/injections.scm
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
(#set! injection.language "comment"))

; Highlight the RHS of `=~` as regex
((regex_literal (_) @injection.content)
((regex_literal
(_) @injection.content)
(#set! injection.language "regex"))

; ================ Global defaults ================
Expand Down
20 changes: 13 additions & 7 deletions queries/just/injections.scm
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@
(#set! injection.language "comment"))

; Highlight the RHS of `=~` as regex
((regex_literal (_) @injection.content)
((regex_literal
(_) @injection.content)
(#set! injection.language "regex"))

; ================ Global defaults ================

; Default everything to be bash
(recipe_body
(#set! injection.language "bash")) @injection.content
(#set! injection.language "bash")
(#set! injection.include-children)) @injection.content

(external_command
(command_body) @injection.content
Expand Down Expand Up @@ -46,7 +48,7 @@
(#set! injection.language "powershell"))
[
(recipe
(recipe_body) @injection.content)
(recipe_body (#set! injection.include-children)) @injection.content)

(assignment
(expression
Expand All @@ -60,7 +62,8 @@
(#not-match? @injection.language ".*(powershell|pwsh|cmd).*"))
[
(recipe
(recipe_body) @injection.content)
(recipe_body
(#set! injection.include-children)) @injection.content)

(assignment
(expression
Expand All @@ -75,7 +78,8 @@
(recipe_body ;
(shebang ;
(language) @injection.language) ;
(#not-any-of? @injection.language "python3" "nodejs" "node")) @injection.content
(#not-any-of? @injection.language "python3" "nodejs" "node")
(#set! injection.include-children)) @injection.content

; Transform some known executables

Expand All @@ -84,11 +88,13 @@
(shebang
(language) @_lang)
(#eq? @_lang "python3")
(#set! injection.language "python")) @injection.content
(#set! injection.language "python")
(#set! injection.include-children)) @injection.content

; node/nodejs -> javascript
(recipe_body
(shebang
(language) @_lang)
(#any-of? @_lang "node" "nodejs")
(#set! injection.language "javascript")) @injection.content
(#set! injection.language "javascript")
(#set! injection.include-children)) @injection.content

0 comments on commit 9d42286

Please sign in to comment.