neovim: fix plugin loading order

fixes https://github.com/NixOS/nixpkgs/issues/188167
This commit is contained in:
Guillaume Girol
2022-08-26 21:17:31 +02:00
committed by Matthieu Coudron
parent f98065ab50
commit 38e16b192a
2 changed files with 30 additions and 0 deletions
@@ -1,3 +1,4 @@
# run tests by building `neovim.tests`
{ vimUtils, vim_configurable, writeText, neovim, vimPlugins
, lib, fetchFromGitHub, neovimUtils, wrapNeovimUnstable
, neovim-unwrapped
@@ -66,6 +67,15 @@ let
sha256 = "1ykcvyx82nhdq167kbnpgwkgjib8ii7c92y3427v986n2s5lsskc";
};
# this plugin checks that it's ftplugin/vim.tex is loaded before $VIMRUNTIME/ftplugin/vim.tex
# the answer is store in `plugin_was_loaded_too_late` in the cwd
texFtplugin = pkgs.runCommandLocal "tex-ftplugin" {} ''
mkdir -p $out/ftplugin
echo 'call system("echo ". exists("b:did_ftplugin") . " > plugin_was_loaded_too_late")' > $out/ftplugin/tex.vim
echo ':q!' >> $out/ftplugin/tex.vim
echo '\documentclass{article}' > $out/main.tex
'';
# neovim-drv must be a wrapped neovim
runTest = neovim-drv: buildCommand:
runCommandLocal "test-${neovim-drv.name}" ({
@@ -128,6 +138,25 @@ rec {
${nvim_with_plug}/bin/nvim -i NONE -c 'color base16-tomorrow-night' +quit! -e
'';
nvim_with_ftplugin = neovim.override {
extraName = "-with-ftplugin";
configure.packages.plugins = with pkgs.vimPlugins; {
start = [
texFtplugin
];
};
};
# regression test that ftplugin files from plugins are loaded before the ftplugin
# files from $VIMRUNTIME
run_nvim_with_ftplugin = runTest nvim_with_ftplugin ''
export HOME=$TMPDIR
${nvim_with_ftplugin}/bin/nvim ${texFtplugin}/main.tex
result="$(cat plugin_was_loaded_too_late)"
echo $result
[ "$result" = 0 ]
'';
# check that the vim-doc hook correctly generates the tag
# we know for a fact packer has a doc folder
@@ -106,6 +106,7 @@ let
flags = [
"--cmd" (lib.intersperse "|" hostProviderViml)
"--cmd" "set packpath^=${vimUtils.packDir packDirArgs}"
"--cmd" "set rtp^=${vimUtils.packDir packDirArgs}"
];
in
[