Closed adigitoleo closed 1 year ago
I guess it has to do with bootstrapping. After consulting :h paq-bootstrapping
, the following works:
nvim-test.sh:
#!/bin/sh
rm -rf .nvimdata
export XDG_DATA_HOME=.nvimdata
nvim -u init.lua
init.lua:
-- Download package manager (paq-nvim).
local function clone_paq()
local path = vim.fn.stdpath("data") .. "/site/pack/paqs/start/paq-nvim"
local is_installed = vim.fn.empty(vim.fn.glob(path)) == 0
if not is_installed then
vim.fn.system { "git", "clone", "--depth=1", "https://github.com/savq/paq-nvim.git", path }
return true
end
end
-- Install packages, bootstrapping package manager if necessary.
local function bootstrap_paq(packages)
local first_install = clone_paq()
vim.cmd.packadd("paq-nvim")
local paq = require("paq")
if first_install then
vim.notify("Installing plugins... If prompted, hit Enter to continue.")
end
paq(packages)
paq.install()
end
bootstrap_paq {
"savq/paq-nvim",
{ "lewis6991/gitsigns.nvim", run = function() require("gitsigns").setup() end },
}
Now I only wonder if paq.install()
always redownloads everything or if it is safe to always use at startup like this.
OK I figured it out, I can (ab)use _run_hook
to have a config where all of the setup for each plugin is inside the run
parameter of the lua dict. I'm using that here and it works fine, regardless of the plugins being installed or not at launch. One minor inconvenience with this method is that opening nvim will always print the 'Ran hooks for foo' messages which must be cleared with Enter before the editor opens. Perhaps a silent version of _run_hook
could be added, but not a big deal. I'll close this because I was just confused and there is no bug.
You are confused. run
is not for general setup but for compiling/building/downloading dependencies required by a plugin. It's only meant to be run after updates.
In general, Paq is just the plugin manager, it's not a "configuration framework".
In particular, to configure your plugins you can just write the code after calling paq
(or bootstrap_paq
or whatever).
This is a very common misunderstanding tho. I'll probably rename the option to build
to avoid confusion and to match Lazy. I added run
after packer, but in retrospect calling build
makes a lot more sense.
I'm not able to run the setup hook for gitsigns by providing it to the
run
parameter in the paq manifest.To Reproduce
Use the following init.lua
And test the installation with e.g.
Expected behavior
Paq runs the post-install hook and the default setup for gitsigns is configured.
Environment:
nvim --version
: 0.8.3git --version
: 2.40.0