rework grammar to be friendly to injections

want to later support the case of multiple nix-shell directives in injection
This commit is contained in:
2023-07-05 00:01:38 +00:00
parent d5adafbc03
commit c9d79b0734
5 changed files with 114 additions and 149 deletions

8
queries/injections.scm Normal file
View File

@@ -0,0 +1,8 @@
; if we find an interpreter, mark the *entire file* as injected content.
; nix-shell doesn't process the source file before sending it to the interpreter,
; so nix-shell directives like `#!nix-shell -i bash` are both a directive to nix-shell
; and actual language content handled by the specified interpreter.
((source_file
(nix_shell_directive
(interpreter) @injection.language)) @injection.content
(#set! injection.include-children))