diff options
| author | Christian Clason <c.clason@uni-graz.at> | 2023-06-12 09:54:30 -0600 |
|---|---|---|
| committer | Christian Clason <c.clason@uni-graz.at> | 2025-05-12 18:43:40 +0200 |
| commit | 692b051b09935653befdb8f7ba8afdb640adf17b (patch) | |
| tree | 167162b6b129ae04f68c5735078521a72917c742 /runtime/queries/nix/injections.scm | |
| parent | feat(c-family): inherit injections (diff) | |
| download | nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar.gz nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar.bz2 nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar.lz nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar.xz nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar.zst nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.zip | |
feat!: drop modules, general refactor and cleanup
Diffstat (limited to 'runtime/queries/nix/injections.scm')
| -rw-r--r-- | runtime/queries/nix/injections.scm | 219 |
1 files changed, 219 insertions, 0 deletions
diff --git a/runtime/queries/nix/injections.scm b/runtime/queries/nix/injections.scm new file mode 100644 index 000000000..26ba6e2da --- /dev/null +++ b/runtime/queries/nix/injections.scm @@ -0,0 +1,219 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +((comment) @injection.language + . ; this is to make sure only adjacent comments are accounted for the injections + [ + (string_expression + (string_fragment) @injection.content) + (indented_string_expression + (string_fragment) @injection.content) + ] + (#gsub! @injection.language "/%*%s*([%w%p]+)%s*%*/" "%1") + (#set! injection.combined)) + +; #-style Comments +((comment) @injection.language + . ; this is to make sure only adjacent comments are accounted for the injections + [ + (string_expression + (string_fragment) @injection.content) + (indented_string_expression + (string_fragment) @injection.content) + ] + (#gsub! @injection.language "#%s*([%w%p]+)%s*" "%1") + (#set! injection.combined)) + +(apply_expression + function: (_) @_func + argument: [ + (string_expression + ((string_fragment) @injection.content + (#set! injection.language "regex"))) + (indented_string_expression + ((string_fragment) @injection.content + (#set! injection.language "regex"))) + ] + (#match? @_func "(^|\\.)match$") + (#set! injection.combined)) + +(binding + attrpath: (attrpath + (identifier) @_path) + expression: [ + (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|Check)|(pre|post)[A-Z]\\w+|script)$")) + +(apply_expression + function: (_) @_func + argument: (_ + (_)* + (_ + (_)* + (binding + attrpath: (attrpath + (identifier) @_path) + expression: [ + (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$") + (#set! injection.combined)) + +(apply_expression + function: (apply_expression + function: (apply_expression + function: (_) @_func)) + argument: [ + (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)?$") + (#set! injection.combined)) + +((apply_expression + function: (apply_expression + function: (_) @_func) + argument: [ + (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)?$") + (#set! injection.combined)) + +((apply_expression + function: (apply_expression + function: (_) @_func) + argument: [ + (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)?$") + (#set! injection.combined)) + +((apply_expression + function: (apply_expression + function: (apply_expression + function: (_) @_func)) + argument: [ + (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)?$") + (#set! injection.combined)) + +((apply_expression + function: (apply_expression + function: (apply_expression + function: (_) @_func)) + argument: [ + (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)?$") + (#set! injection.combined)) + +((apply_expression + function: (apply_expression + function: (apply_expression + function: (_) @_func)) + argument: [ + (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)?$") + (#set! injection.combined)) + +((apply_expression + function: (apply_expression + function: (apply_expression + function: (_) @_func)) + argument: [ + (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)?$") + (#set! injection.combined)) + +((apply_expression + function: (apply_expression + function: (apply_expression + function: (_) @_func)) + argument: [ + (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)?$") + (#set! injection.combined)) + +; (nixosTest) testScript +((binding + attrpath: (attrpath) @_attr_name + (#eq? @_attr_name "nodes")) + (binding + attrpath: (attrpath) @_func_name + (#eq? @_func_name "testScript") + (_ + (string_fragment) @injection.content + (#set! injection.language "python"))) + (#set! injection.combined)) + +; home-manager Neovim plugin config +(attrset_expression + (binding_set + (binding + attrpath: (attrpath) @_ty_attr + (_ + (string_fragment) @_ty) + (#eq? @_ty_attr "type") + (#eq? @_ty "lua")) + (binding + attrpath: (attrpath) @_cfg_attr + (_ + (string_fragment) @injection.content + (#set! injection.language "lua")) + (#eq? @_cfg_attr "config"))) + (#set! injection.combined)) |
