diff --git a/pkgs/by-name/tree-sitter-nix-shell/package.nix b/pkgs/by-name/tree-sitter-nix-shell/package.nix index 49aea8f13..47763d11d 100644 --- a/pkgs/by-name/tree-sitter-nix-shell/package.nix +++ b/pkgs/by-name/tree-sitter-nix-shell/package.nix @@ -1,18 +1,21 @@ -{ lib -, fetchFromGitea -, htmlq -, tree-sitter -, tree-sitter-nix-shell +{ + fetchFromGitea, + htmlq, + lib, + neovimUtils, + tree, + tree-sitter, + tree-sitter-nix-shell, }: tree-sitter.buildGrammar { - version = "0.1.0"; + version = "0.2.0"; src = fetchFromGitea { domain = "git.uninsane.org"; owner = "colin"; repo = "tree-sitter-nix-shell"; - rev = "c2fcc8b6ee91af2cb58a38f62c0800f82d783738"; - hash = "sha256-NU7p4KieSkYRhTSgL5qwFJ9n7hGJwTn0rynicfOf9oA="; + rev = "41849dc40d776841a3104d15c8b8ac69425f17f7"; + hash = "sha256-6+I3EiKj82yzyteV1jkhI2aHaBPw5E7cLUztnYhieWk="; }; language = "nix-shell"; @@ -21,17 +24,39 @@ tree-sitter.buildGrammar { nativeCheckInputs = [ htmlq ]; checkPhase = '' + runHook preCheck (cd ..; make test) + runHook postCheck ''; doCheck = true; + nativeInstallCheckInputs = [ tree ]; + installCheckPhase = '' + runHook preInstallCheck + + # i'm too dumb to know which installed files are necessary for e.g. neovim, + # but the original package (pre 2025-03-15) had: + # - $out/parser (elf file; also found in e.g. vimPlugins.nvim-treesitter.grammarPlugins.latex.origGrammar) + # - $out/queries/{highlights.scm,injections.scm} + # + # N.B. that said original parser never actually worked with neovim (only with helix?) + (test -x $out/parser && test -f $out/queries/highlights.scm && test -f $out/queries/injections.scm) || \ + (tree $out; echo "expected output to contain /parser and /queries/"; false) + + runHook postInstallCheck + ''; + doInstallCheck = true; + passthru = { generated = tree-sitter-nix-shell.overrideAttrs (orig: { # provide a package which has the output of `tree-sitter generate`, but not the binary compiled parser - buildPhase = "true"; + dontBuild = true; installPhase = "cp -r . $out"; - checkPhase = "true"; + doCheck = false; + doInstallCheck = false; }); + # see comment in + nvimPlugin = neovimUtils.grammarToPlugin tree-sitter-nix-shell; }; meta = with lib; {