diff options
| author | Marc Jakobi <marc.jakobi@tiko.energy> | 2023-06-28 16:34:13 +0200 |
|---|---|---|
| committer | Christian Clason <c.clason@uni-graz.at> | 2025-05-12 18:43:40 +0200 |
| commit | 628d5e442c7c572f4d83bb551154a102eaeeafb3 (patch) | |
| tree | c5af8efa8266aa891d7fa9a43b1c8d71ff0adce1 | |
| parent | feat(yuck): add missing injections (diff) | |
| download | nvim-treesitter-628d5e442c7c572f4d83bb551154a102eaeeafb3.tar nvim-treesitter-628d5e442c7c572f4d83bb551154a102eaeeafb3.tar.gz nvim-treesitter-628d5e442c7c572f4d83bb551154a102eaeeafb3.tar.bz2 nvim-treesitter-628d5e442c7c572f4d83bb551154a102eaeeafb3.tar.lz nvim-treesitter-628d5e442c7c572f4d83bb551154a102eaeeafb3.tar.xz nvim-treesitter-628d5e442c7c572f4d83bb551154a102eaeeafb3.tar.zst nvim-treesitter-628d5e442c7c572f4d83bb551154a102eaeeafb3.zip | |
injections(nix): add nixosTest.testScript + home-manager nvim config
(+ add Check to mkDerivation bash matches)
(+ add Check to mkDerivation bash matches)
| -rw-r--r-- | queries/nix/injections.scm | 29 | ||||
| -rw-r--r-- | tests/query/injections/nix/test-nix-injections.nix | 70 |
2 files changed, 99 insertions, 0 deletions
diff --git a/queries/nix/injections.scm b/queries/nix/injections.scm index d5e8483f4..26ba6e2da 100644 --- a/queries/nix/injections.scm +++ b/queries/nix/injections.scm @@ -188,3 +188,32 @@ ]) (#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)) diff --git a/tests/query/injections/nix/test-nix-injections.nix b/tests/query/injections/nix/test-nix-injections.nix new file mode 100644 index 000000000..86e9f975d --- /dev/null +++ b/tests/query/injections/nix/test-nix-injections.nix @@ -0,0 +1,70 @@ +{ pkgs, stdenv }: +# NOTE: This file is for testing queries. If evaluated with nix, this will probably error. +{ + regex = builtins.match "^.*[{](.+)[}].*$" "blahblah {something} blahblah" [ "something" ]; + + drv1 = stdenv.mkDerivation { + buildPhase = "mkdir $out"; + installPhase = '' + echo "bar" > $out/foo.txt + ''; + }; + + drv2 = pkgs.writeShellApplication { + name = "shellApp"; + buildInputs = []; + text = '' + echo "Hello world!" + ''; + }; + + drv3 = pkgs.runCommand "foo-bar" {} '' + mkir $out + echo "bar" > $out/foo.txt + ''; + + drv4 = pkgs.writeShellScriptBin "hello" '' + echo "Hello world!" + ''; + + drv5 = pkgs.writeFishBin "hello" '' + echo "Hello world!" + ''; + + drv6 = pkgs.writeHaskellBin "hello" '' + main :: IO () + main = putStrLn "Hello world!" + ''; + + drv7 = pkgs.writeJSBin "hello" '' + console.log('Hello world!'); + ''; + + drv8 = pkgs.writePerlBin "hello" '' + print("Hello world!\n"); + ''; + + drv9 = pkgs.writePythonBin "hello" '' + print("Hello world!"); + ''; + + drv10 = pkgs.writeRustBin "hello" '' + fn main() { + println!("Hello world!"); + } + ''; + + drv11 = { + nodes = null; + testScript = '' + print("Hello world!"); + ''; + }; + + mod1 = { + type = "lua"; + config = '' + require('nvim-treesitter.configs').setup() + ''; + }; +} |
