diff options
author | Timothy DeHerrera | 2022-08-29 02:16:10 +0000 |
---|---|---|
committer | Michael Davis | 2022-09-06 22:39:41 +0000 |
commit | 665e27ff9dc017ee47f646187d98f5e4cdb18411 (patch) | |
tree | 5018c45ae2b7f43649c2925a934848ec13a491ea /runtime | |
parent | 43b31f702a13d3ced2dc414d2febe5bcf222366a (diff) |
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.
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/queries/nix/injections.scm | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/runtime/queries/nix/injections.scm b/runtime/queries/nix/injections.scm new file mode 100644 index 00000000..82d79cc7 --- /dev/null +++ b/runtime/queries/nix/injections.scm @@ -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)) |