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

How do you load config file? #81

medwatt opened this issue Oct 10, 2021 · 5 comments

How do you load config file? #81

medwatt opened this issue Oct 10, 2021 · 5 comments
question Further information is requested


Copy link

medwatt commented Oct 10, 2021

I currently have this in my init.lua. As long as the plugin is not installed, I get an error on startup telling me the plugin is not installed. If I install the plugin, then the code works fine and runs the config file. Let's say I delete my plugins folder and want to reinstall everything from scratch. Then, I will have to all the lines with the run option, install the plugins, and reinsert the line back. Surely, there has to be a better way to do this.

require "paq" {
    {'folke/which-key.nvim', run = require('main.plugin_config.which-key_config')}
Copy link

I just have separate calls, like so:

-- Use paq to install plugins
require "paq" {

-- hardline status and tab line
require('hardline').setup {
        theme = 'default'

Copy link

Bowuigi commented Dec 7, 2021

Replace whatever is on the run with the following:

function() if pcall(require, "[plugin]") then require("main.plugin_config.[plugin]_config")() end end

Here is a function to generate all of this automagically:

function PConfig(plugin)
    return function() if pcall(require, plugin) then require("main.plugin_config."..plugin.."_config")() end end

So you could just do, for example:

require("paq") {
    {"folke/which-key.nvim", run = PConfig("which-key")}

@savq savq added the question Further information is requested label Dec 10, 2021
Copy link

RayZ0rr commented Jan 13, 2022

Here is a function to generate all of this automagically:

This looks like a neat little alternative to config in packer. @savq Could you add this to README or the wiki ?

Copy link

Any thoughts on if this is still the way to achieve such packer-esque behaviour for collocating plugin configs? Since run only seems to run post-install; how does this work to actively do the config require sourcing each time you load nvim? @Bowuigi / @savq -- thank you for this amazing plugin!

Copy link

RayZ0rr commented Mar 10, 2022

I don't think this fits paq's minimalistic nature. One solution to this problem is to put plugins and configurations in a table and then load them separately. Eg from my own config:

local plugAndConfig = {

  -- Each element should be like this:
  -- {'plugin/name','config name used in require'}
  -- config name is optional

  -- Let Paq (plugin manager) manage itself


  -- fzf ----------------------------------------
  -- Undo history ------------------------------
  -- Build, Run tasks (commands) in background asynchronously
  -- File Browser ------------------------------
  -- Autocompletion plugin ---------------------
  -- Other plugins and configs

local plugList = {}
local configList = {}

for idx, items in pairs(plugAndConfig) do
  plugList[idx] = items[1]
  if items[2] then

-- don't throw any error on first use by packer
local ok, paq = pcall(require, "paq")
if not ok then return end


-- Load configs
for idx, config in pairs(configList) do

@medwatt medwatt closed this as completed Mar 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
question Further information is requested
None yet

No branches or pull requests

6 participants