mirror of
https://github.com/ilyakooo0/helix.git
synced 2024-09-11 16:07:00 +03:00
nix: add language injections
By simply placing a comment with the name of the desired language just before a multi-line string, that language will be injected. Also, common functions and attributes which are expected to be shell code are automatically injected.
This commit is contained in:
parent
43b31f702a
commit
665e27ff9d
39
runtime/queries/nix/injections.scm
Normal file
39
runtime/queries/nix/injections.scm
Normal file
@ -0,0 +1,39 @@
|
||||
; mark arbitary languages with a comment
|
||||
((((comment) @injection.language) .
|
||||
(indented_string_expression (string_fragment) @injection.content))
|
||||
(#set! injection.combined))
|
||||
|
||||
((binding
|
||||
attrpath: (attrpath (identifier) @_path)
|
||||
expression: (indented_string_expression
|
||||
(string_fragment) @injection.content))
|
||||
(#match? @_path "(^\\w*Phase|(pre|post)\\w*|(.*\\.)?\\w*([sS]cript|[hH]ook)|(.*\\.)?startup)$")
|
||||
(#set! injection.language "bash")
|
||||
(#set! injection.combined))
|
||||
|
||||
((apply_expression
|
||||
function: (apply_expression function: (_) @_func)
|
||||
argument: (indented_string_expression (string_fragment) @injection.content))
|
||||
(#match? @_func "(^|\\.)writeShellScript(Bin)?$")
|
||||
(#set! injection.language "bash")
|
||||
(#set! injection.combined))
|
||||
|
||||
(apply_expression
|
||||
(apply_expression
|
||||
function: (apply_expression
|
||||
function: ((_) @_func)))
|
||||
argument: (indented_string_expression (string_fragment) @injection.content)
|
||||
(#match? @_func "(^|\\.)runCommand(((No)?(CC))?(Local)?)?$")
|
||||
(#set! injection.language "bash")
|
||||
(#set! injection.combined))
|
||||
|
||||
(apply_expression
|
||||
function: ((_) @_func)
|
||||
argument: (_ (_)* (_ (_)* (binding
|
||||
attrpath: (attrpath (identifier) @_path)
|
||||
expression: (indented_string_expression
|
||||
(string_fragment) @injection.content))))
|
||||
(#match? @_func "(^|\\.)writeShellApplication$")
|
||||
(#match? @_path "^text$")
|
||||
(#set! injection.language "bash")
|
||||
(#set! injection.combined))
|
Loading…
Reference in New Issue
Block a user