Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to run setup hook for gitsigns #143

Closed
adigitoleo opened this issue Apr 7, 2023 · 3 comments
Closed

Unable to run setup hook for gitsigns #143

adigitoleo opened this issue Apr 7, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@adigitoleo
Copy link

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

require "paq" {
    "savq/paq-nvim",
    { "lewis6991/gitsigns.nvim", run = function() require("gitsigns").setup() end },
}

And test the installation with e.g.

#!/bin/sh

# Clone paq (package manager)
rm -rf .nvimdata
git clone --depth=1 https://github.com/savq/paq-nvim.git \
    .nvimdata/nvim/site/pack/paqs/start/paq-nvim
# Set plugin directory.
export XDG_DATA_HOME=.nvimdata
# Launch with the test config.
nvim -u init.lua -c PaqInstall

Expected behavior

Paq runs the post-install hook and the default setup for gitsigns is configured.

Environment:

  • nvim --version: 0.8.3
  • git --version: 2.40.0
  • OS: Void Linux glibc x86_64
@adigitoleo adigitoleo added the bug Something isn't working label Apr 7, 2023
@adigitoleo
Copy link
Author

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.

@adigitoleo
Copy link
Author

adigitoleo commented Apr 8, 2023

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.

@savq
Copy link
Owner

savq commented Apr 9, 2023

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.

savq added a commit that referenced this issue Aug 5, 2023
Public API:
- Rename `run` option to `build`.
- Rename `PaqRunHook` command to `PaqBuild`.

Paq will print a deprecation notice if the old names are used.
The reason for these renames is explained in #143.

Internals:
- Refactor build related functions to ensure the build are executed
  after all packages have been installed/updated and loaded:
  - If the hook is a function, it might require a module inside a
    recently installed package.
  - If a is package is installed successfully and the build fails,
    it's better to notify that in two separate messages, instead of
    notifying the install failed.
  - To ensure only the necessary builds

- Rename `run_hook` to `run_build`, and refactor to make it clear
  there's 3 possible cases: function, ex command, shell commmand.

- Refactor `new_counter` to take a callback (passed in `exe_op`).
savq added a commit that referenced this issue Aug 6, 2023
Public API:
- Rename `run` option to `build`.
- Rename `PaqRunHook` command to `PaqBuild`.

Paq will print a deprecation notice if the old names are used.
The reason for these renames is explained in #143.

Internals:
- Refactor build related functions to ensure the build are executed
  after all packages have been installed/updated and loaded:
  - If the hook is a function, it might require a module inside a
    recently installed package.
  - If a is package is installed successfully and the build fails,
    it's better to notify that in two separate messages, instead of
    notifying the install failed.
  - To ensure only the necessary builds

- Rename `run_hook` to `run_build`, and refactor to make it clear
  there's 3 possible cases: function, ex command, shell commmand.

- Refactor `new_counter` to take a callback (passed in `exe_op`).
savq added a commit that referenced this issue Sep 3, 2023
Public API:
- Rename `run` option to `build`.
- Rename `PaqRunHook` command to `PaqBuild`.

Paq will print a deprecation notice if the old names are used.
The reason for these renames is explained in #143.

Internals:
- Refactor build related functions to ensure the build are executed
  after all packages have been installed/updated and loaded:
  - If the hook is a function, it might require a module inside a
    recently installed package.
  - If a is package is installed successfully and the build fails,
    it's better to notify that in two separate messages, instead of
    notifying the install failed.
  - To ensure only the necessary builds

- Rename `run_hook` to `run_build`, and refactor to make it clear
  there's 3 possible cases: function, ex command, shell commmand.

- Refactor `new_counter` to take a callback (passed in `exe_op`).
savq added a commit that referenced this issue Sep 3, 2023
Public API:
- Rename `run` option to `build`.
- Rename `PaqRunHook` command to `PaqBuild`.

Paq will print a deprecation notice if the old names are used.
The reason for these renames is explained in #143.

Internals:
- Refactor build related functions to ensure the build are executed
  after all packages have been installed/updated and loaded:
  - If the hook is a function, it might require a module inside a
    recently installed package.
  - If a is package is installed successfully and the build fails,
    it's better to notify that in two separate messages, instead of
    notifying the install failed.
  - To ensure only the necessary builds

- Rename `run_hook` to `run_build`, and refactor to make it clear
  there's 3 possible cases: function, ex command, shell commmand.

- Refactor `new_counter` to take a callback (passed in `exe_op`).
@savq savq mentioned this issue Sep 3, 2023
savq added a commit that referenced this issue Sep 3, 2023
Public API:
- Rename `run` option to `build`.
- Rename `PaqRunHook` command to `PaqBuild`.

Paq will print a deprecation notice if the old names are used.
The reason for renaming these is explained in #143.

Internals:
- Refactor build related functions to ensure builds are executed after
  all packages have been installed/updated and loaded:
  - If the hook is a function, it might require a module inside a
    recently installed package.
  - If a is package is installed successfully and the build fails,
    it's better to notify that in two separate messages, instead of
    notifying the install failed.

- Rename `run_hook` to `run_build`, and refactor to make it clear
  there's 3 possible cases: function, ex command, shell commmand.

- Refactor `new_counter` to take a callback (passed in `exe_op`).
savq added a commit that referenced this issue Sep 3, 2023
Public API:
- Rename `run` option to `build`.
- Rename `PaqRunHook` command to `PaqBuild`.

Paq will print a deprecation notice if the old names are used.
The reason for renaming these is explained in #143.

Internals:
- Refactor build related functions to ensure builds are executed after
  all packages have been installed/updated and loaded:
  - If the hook is a function, it might require a module inside a
    recently installed package.
  - If a is package is installed successfully and the build fails,
    it's better to notify that in two separate messages, instead of
    notifying the install failed.

- Rename `run_hook` to `run_build`, and refactor to make it clear
  there's 3 possible cases: function, ex command, shell commmand.

- Refactor `new_counter` to take a callback (passed in `exe_op`).
savq added a commit that referenced this issue Oct 20, 2023
Public API:
- Rename `run` option to `build`.
- Rename `PaqRunHook` command to `PaqBuild`.

Paq will print a deprecation notice if the old names are used.
The reason for renaming these is explained in #143.

Internals:
- Refactor build related functions to ensure builds are executed after
  all packages have been installed/updated and loaded:
  - If the hook is a function, it might require a module inside a
    recently installed package.
  - If a is package is installed successfully and the build fails,
    it's better to notify that in two separate messages, instead of
    notifying the install failed.

- Rename `run_hook` to `run_build`, and refactor to make it clear
  there's 3 possible cases: function, ex command, shell commmand.

- Refactor `new_counter` to take a callback (passed in `exe_op`).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants