mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-03 12:23:02 +00:00
buildVimPlugin: add vimCommandCheckHook
Modeled after pythonImportCheckHook, this checks a command can be run once the plugin is installed
This commit is contained in:
parent
2415f1e0a5
commit
9663a29afa
@ -1,6 +1,7 @@
|
||||
{ lib, stdenv
|
||||
, rtpPath
|
||||
, vim
|
||||
, vimCommandCheckHook
|
||||
, vimGenDocHook
|
||||
}:
|
||||
|
||||
@ -30,6 +31,7 @@ rec {
|
||||
forceShare= [ "man" "info" ];
|
||||
|
||||
nativeBuildInputs = attrs.nativeBuildInputs or []
|
||||
++ [ vimCommandCheckHook ]
|
||||
++ lib.optional (stdenv.hostPlatform == stdenv.buildPlatform) vimGenDocHook;
|
||||
inherit unpackPhase configurePhase buildPhase addonInfo preInstall postInstall;
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
let
|
||||
|
||||
inherit (vimUtils.override {inherit vim;}) buildVimPluginFrom2Nix vimGenDocHook;
|
||||
inherit (vimUtils.override {inherit vim;}) buildVimPluginFrom2Nix vimGenDocHook vimCommandCheckHook;
|
||||
|
||||
inherit (lib) extends;
|
||||
|
||||
@ -12,7 +12,10 @@ let
|
||||
toVimPlugin = drv:
|
||||
drv.overrideAttrs(oldAttrs: {
|
||||
|
||||
nativeBuildInputs = oldAttrs.nativeBuildInputs or [] ++ [ vimGenDocHook ];
|
||||
nativeBuildInputs = oldAttrs.nativeBuildInputs or [] ++ [
|
||||
vimGenDocHook
|
||||
vimCommandCheckHook
|
||||
];
|
||||
passthru = (oldAttrs.passthru or {}) // {
|
||||
vimPlugin = true;
|
||||
};
|
||||
|
@ -450,11 +450,8 @@ self: super: {
|
||||
--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!
|
||||
'';
|
||||
|
||||
doInstallCheck = true;
|
||||
vimCommandCheck = "MinimapToggle";
|
||||
});
|
||||
|
||||
ncm2 = super.ncm2.overrideAttrs (old: {
|
||||
|
@ -0,0 +1,25 @@
|
||||
# Setup hook for checking whether a vim command exists
|
||||
echo "Sourcing vim-command-check-hook.sh"
|
||||
|
||||
vimCommandCheckHook () {
|
||||
echo "Executing vimCommandCheckHook"
|
||||
|
||||
if [ -n "$vimCommandCheck" ]; then
|
||||
echo "Check whether the following modules can be imported: $vimCommandCheck"
|
||||
|
||||
# editorconfig-checker-disable
|
||||
export HOME="$TMPDIR"
|
||||
@vimBinary@ -es -n -u NONE -i NONE --clean -V1 --cmd "set rtp+=$out" \
|
||||
--cmd "runtime! plugin/*.vim" <<-EOF
|
||||
if exists(":$vimCommandCheck") == 2
|
||||
cquit 0
|
||||
else
|
||||
cquit 1
|
||||
fi
|
||||
EOF
|
||||
fi
|
||||
}
|
||||
|
||||
echo "Using vimCommandCheckHook"
|
||||
preDistPhases+=" vimCommandCheckHook"
|
||||
|
@ -521,8 +521,19 @@ rec {
|
||||
};
|
||||
} ./vim-gen-doc-hook.sh) {};
|
||||
|
||||
inherit (import ./build-vim-plugin.nix { inherit lib stdenv rtpPath vim vimGenDocHook; })
|
||||
buildVimPlugin buildVimPluginFrom2Nix;
|
||||
vimCommandCheckHook = callPackage ({ neovim-unwrapped }:
|
||||
makeSetupHook {
|
||||
name = "vim-command-check-hook";
|
||||
deps = [ neovim-unwrapped ];
|
||||
substitutions = {
|
||||
vimBinary = "${neovim-unwrapped}/bin/nvim";
|
||||
inherit rtpPath;
|
||||
};
|
||||
} ./vim-command-check-hook.sh) {};
|
||||
|
||||
inherit (import ./build-vim-plugin.nix {
|
||||
inherit lib stdenv rtpPath vim vimGenDocHook vimCommandCheckHook;
|
||||
}) buildVimPlugin buildVimPluginFrom2Nix;
|
||||
|
||||
# used to figure out which python dependencies etc. neovim needs
|
||||
requiredPlugins = {
|
||||
|
Loading…
Reference in New Issue
Block a user