From 761b2c6ff342425388db38b86f1c49cbdb232514 Mon Sep 17 00:00:00 2001 From: Matthieu Coudron Date: Tue, 14 Sep 2021 21:49:16 +0200 Subject: [PATCH 1/5] neovim.tests: complete plug test to check that it can correctly load the colorscheme --- pkgs/applications/editors/neovim/tests.nix | 11 ++++++++++- pkgs/misc/vim-plugins/build-vim-plugin.nix | 2 +- pkgs/misc/vim-plugins/vim-utils.nix | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/pkgs/applications/editors/neovim/tests.nix b/pkgs/applications/editors/neovim/tests.nix index 202b18efb8cfb..e442de6939bd5 100644 --- a/pkgs/applications/editors/neovim/tests.nix +++ b/pkgs/applications/editors/neovim/tests.nix @@ -87,10 +87,19 @@ rec { nvim_with_plug = neovim.override { extraName = "-with-plug"; configure.plug.plugins = with pkgs.vimPlugins; [ - vim-go + base16-vim ]; + configure.customRC = '' + color base16-tomorrow-night + set background=dark + ''; }; + run_nvim_with_plug = runTest nvim_with_plug '' + export HOME=$TMPDIR + ${nvim_with_plug}/bin/nvim -i NONE -c 'color base16-tomorrow-night' +quit! + ''; + # nixpkgs should detect that no wrapping is necessary nvimShouldntWrap = wrapNeovim2 "-should-not-wrap" nvimAutoDisableWrap; diff --git a/pkgs/misc/vim-plugins/build-vim-plugin.nix b/pkgs/misc/vim-plugins/build-vim-plugin.nix index b6c75e03654d8..90960da7844ab 100644 --- a/pkgs/misc/vim-plugins/build-vim-plugin.nix +++ b/pkgs/misc/vim-plugins/build-vim-plugin.nix @@ -6,7 +6,7 @@ rec { addRtp = path: attrs: derivation: - derivation // { rtp = "${derivation}/${path}"; } // { + derivation // { rtp = "${derivation}"; } // { overrideAttrs = f: buildVimPlugin (attrs // f attrs); }; diff --git a/pkgs/misc/vim-plugins/vim-utils.nix b/pkgs/misc/vim-plugins/vim-utils.nix index 0516a84ce953c..28512e5ede647 100644 --- a/pkgs/misc/vim-plugins/vim-utils.nix +++ b/pkgs/misc/vim-plugins/vim-utils.nix @@ -295,7 +295,7 @@ let plugImpl = ('' source ${vimPlugins.vim-plug.rtp}/plug.vim - call plug#begin('/dev/null') + silent! call plug#begin('/dev/null') '' + (lib.concatMapStringsSep "\n" (pkg: "Plug '${pkg.rtp}'") plug.plugins) + '' From 087e816e377d3ea22f427944b8c7ff6d74d3dec5 Mon Sep 17 00:00:00 2001 From: Matthieu Coudron Date: Thu, 16 Sep 2021 14:30:37 +0200 Subject: [PATCH 2/5] vimUtils: expose packDir --- pkgs/misc/vim-plugins/vim-utils.nix | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/pkgs/misc/vim-plugins/vim-utils.nix b/pkgs/misc/vim-plugins/vim-utils.nix index 28512e5ede647..3e609b5751198 100644 --- a/pkgs/misc/vim-plugins/vim-utils.nix +++ b/pkgs/misc/vim-plugins/vim-utils.nix @@ -187,8 +187,9 @@ let rtpPath = "."; - nativeImpl = packages: - (let + # Generates a packpath folder as expected by vim + packDir = packages: + let # dir is "start" or "opt" linkLuaPlugin = plugin: packageName: dir: '' mkdir -p $out/pack/${packageName}/${dir}/${plugin.pname}/lua @@ -205,7 +206,7 @@ let then linkLuaPlugin pluginPath else linkVimlPlugin pluginPath; - packageLinks = (packageName: {start ? [], opt ? []}: + packageLinks = packageName: {start ? [], opt ? []}: let # `nativeImpl` expects packages to be derivations, not strings (as # opposed to older implementations that have to maintain backwards @@ -230,21 +231,20 @@ let ++ [ "mkdir -p $out/pack/${packageName}/start/__python3_dependencies" "ln -s ${python3Env}/${python3Env.sitePackages} $out/pack/${packageName}/start/__python3_dependencies/python3" - ] - ); - packDir = (packages: + ]; + in stdenv.mkDerivation { name = "vim-pack-dir"; src = ./.; installPhase = lib.concatStringsSep "\n" (lib.flatten (lib.mapAttrsToList packageLinks packages)); preferLocalBuild = true; - } - ); - in + }; + + nativeImpl = packages: '' set packpath^=${packDir packages} set runtimepath^=${packDir packages} - ''); + ''; /* Generates a vimrc string From 57131f173e4aeeb074715d64a34ced5eabcdc033 Mon Sep 17 00:00:00 2001 From: Matthieu Coudron Date: Thu, 16 Sep 2021 18:45:32 +0200 Subject: [PATCH 3/5] vimUtils.vimGenDocHook: fix tag generation --- pkgs/misc/vim-plugins/build-vim-plugin.nix | 3 +++ pkgs/misc/vim-plugins/vim-gen-doc-hook.sh | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/pkgs/misc/vim-plugins/build-vim-plugin.nix b/pkgs/misc/vim-plugins/build-vim-plugin.nix index 90960da7844ab..5b235188c06ab 100644 --- a/pkgs/misc/vim-plugins/build-vim-plugin.nix +++ b/pkgs/misc/vim-plugins/build-vim-plugin.nix @@ -26,6 +26,9 @@ rec { addRtp "${rtpPath}/${path}" attrs (stdenv.mkDerivation (attrs // { name = namePrefix + name; + # dont move the doc folder since vim expects it + forceShare= [ "man" "info" ]; + nativeBuildInputs = attrs.nativeBuildInputs or [] ++ [ vimGenDocHook ]; inherit unpackPhase configurePhase buildPhase addonInfo preInstall postInstall; diff --git a/pkgs/misc/vim-plugins/vim-gen-doc-hook.sh b/pkgs/misc/vim-plugins/vim-gen-doc-hook.sh index cbf666f8b74d8..d5f0a00ebcc28 100644 --- a/pkgs/misc/vim-plugins/vim-gen-doc-hook.sh +++ b/pkgs/misc/vim-plugins/vim-gen-doc-hook.sh @@ -5,7 +5,7 @@ echo "Sourcing vim-gen-doc-hook" vimPluginGenTags() { echo "Executing vimPluginGenTags" - target="$out/@rtpPath@/$pname" + target="$out/@rtpPath@" mkdir -p $out/@rtpPath@ # build help tags @@ -16,7 +16,7 @@ vimPluginGenTags() { exit 1 fi else - echo "No docs available" + echo "No docs available for $target" fi if [ -n "$addonInfo" ]; then From 22caffad3a2b32a0be38cd2a3a1e1953f3d153f0 Mon Sep 17 00:00:00 2001 From: Matthieu Coudron Date: Thu, 16 Sep 2021 18:46:27 +0200 Subject: [PATCH 4/5] vimPlugins.minimap-vim: add test --- pkgs/misc/vim-plugins/overrides.nix | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkgs/misc/vim-plugins/overrides.nix b/pkgs/misc/vim-plugins/overrides.nix index 9b0cae766e1ca..a80ed2061e584 100644 --- a/pkgs/misc/vim-plugins/overrides.nix +++ b/pkgs/misc/vim-plugins/overrides.nix @@ -37,6 +37,9 @@ , xkb-switch , ycmd +# test dependencies +, neovim-unwrapped + # command-t dependencies , rake , ruby @@ -392,6 +395,12 @@ self: super: { substituteInPlace $out/bin/minimap_generator.sh \ --replace "code-minimap" "${code-minimap}/bin/code-minimap" ''; + + doCheck = true; + checkPhase = '' + ${neovim-unwrapped}/bin/nvim -n -u NONE -i NONE -V1 --cmd "set rtp+=$out" --cmd "runtime! plugin/*.vim" -c "MinimapToggle" +quit! + ''; + }); ncm2 = super.ncm2.overrideAttrs (old: { From cae999f7a36027deb00ff3ad77cf02a09de8f0b5 Mon Sep 17 00:00:00 2001 From: Matthieu Coudron Date: Thu, 16 Sep 2021 22:22:25 +0200 Subject: [PATCH 5/5] neovim.tests: add a test for tags generation packer.nvim has a doc/ folder so the vim doc hook should generate a 'tags' file --- pkgs/applications/editors/neovim/tests.nix | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pkgs/applications/editors/neovim/tests.nix b/pkgs/applications/editors/neovim/tests.nix index e442de6939bd5..085fceac11084 100644 --- a/pkgs/applications/editors/neovim/tests.nix +++ b/pkgs/applications/editors/neovim/tests.nix @@ -100,6 +100,17 @@ rec { ${nvim_with_plug}/bin/nvim -i NONE -c 'color base16-tomorrow-night' +quit! ''; + + # check that the vim-doc hook correctly generates the tag + # we know for a fact packer has a doc folder + checkForTags = vimPlugins.packer-nvim.overrideAttrs(oldAttrs: { + doInstallCheck = true; + installCheckPhase = '' + [ -f $out/doc/tags ] + ''; + }); + + # nixpkgs should detect that no wrapping is necessary nvimShouldntWrap = wrapNeovim2 "-should-not-wrap" nvimAutoDisableWrap;