mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-07-06 17:13:24 -05:00
neovim-require-check-hook: remove $out from rtp
Previously, the tested plugin appeared in `rtp` under two paths: - `/nix/store/<hash>-vimPlugins-my-plugin` from `$out` - `/build/.local/share/nvim/site/pack/nvimRequireCheckHook/opt/testPlugin` from `packadd testPlugin` This was causing problems for plugins that use `vim.api.nvim_get_runtime_file()`. For example, plugins that use `blink.lib` to load rust modules fail the require check because `blink.lib` uses this function to locate rust shared libraries and raises an error when duplicate libraries are found. The plugin is already loaded via `packadd testPlugin`, so adding `$out` to `rtp` is unnecessary. Remove `$out` from `rtp` to avoid duplicate runtime entries, and add a regression test to ensure the plugin appears in `rtp` only once. Co-authored-by: Austin Horstman <khaneliman12@gmail.com>
This commit is contained in:
parent
dc9c70122a
commit
bb1e73bf6f
2 changed files with 24 additions and 3 deletions
|
|
@ -558,4 +558,25 @@ pkgs.lib.recurseIntoAttrs rec {
|
|||
EOF
|
||||
'';
|
||||
};
|
||||
|
||||
nvim_require_check_rtp_no_duplicate = vimUtils.buildVimPlugin {
|
||||
pname = "neovim-require-check-rtp-no-duplicate-test";
|
||||
version = "0";
|
||||
src = runCommandLocal "neovim-require-check-rtp-no-duplicate-src" { } ''
|
||||
mkdir -p "$out/lua/require-check-rtp-dedup"
|
||||
cat > "$out/lua/require-check-rtp-dedup/init.lua" <<'EOF'
|
||||
local target = "lua/require-check-rtp-dedup/init.lua"
|
||||
local matches = vim.api.nvim_get_runtime_file(target, true)
|
||||
if #matches ~= 1 then
|
||||
error(
|
||||
("expected plugin on runtimepath exactly once, found %d:\n%s"):format(
|
||||
#matches,
|
||||
table.concat(matches, "\n")
|
||||
)
|
||||
)
|
||||
end
|
||||
return {}
|
||||
EOF
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -98,9 +98,9 @@ run_require_checks() {
|
|||
if [ "$skip" = false ]; then
|
||||
echo "Attempting to require module: $name"
|
||||
if @nvimBinary@ -es --headless -n -u NONE -i NONE --clean -V1 \
|
||||
--cmd "set rtp+=$out,${deps// /,}" \
|
||||
--cmd "set rtp+=$out,${nativeCheckInputs// /,}" \
|
||||
--cmd "set rtp+=$out,${checkInputs// /,}" \
|
||||
--cmd "set rtp+=${deps// /,}" \
|
||||
--cmd "set rtp+=${nativeCheckInputs// /,}" \
|
||||
--cmd "set rtp+=${checkInputs// /,}" \
|
||||
"${luaPathArgs[@]}" \
|
||||
--cmd "set packpath^=$packPathDir" \
|
||||
--cmd "packadd testPlugin" \
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue