nvim-neorocks / rocks-config.nvim

Allow rocks.nvim to help configure your plugins.
GNU General Public License v3.0
55 stars 2 forks source link

[Bug] Lua plugin configs are not loaded #53

Closed jgregoire closed 1 month ago

jgregoire commented 1 month ago

@vhyrro we talked about this on Discord last week. Figured I would make an issue.

rocks-config is not loading files in lua/plugins/

Minimal config is here: https://github.com/jgregoire/dotfiles/tree/rocks.nvim/nvim

rocks.nvim itself is working fine, and I ran :Rocks sync before testing this latest config.

jgregoire commented 1 month ago

Ok weird. This might be coincidence, but I just installed rocks-edit and suddenly my keybinds (legendary.nvim) are being loaded. But not my colorscheme.

:checkhealth rocks

rocks: require("rocks.health").check()

Checking external dependencies ~
- OK luarocks: found /home/james/.local/share/nvim/rocks/bin/luarocks 3.11.1
- OK lua: found Lua 5.1.5  Copyright (C) 1994-2012 Lua.org, PUC-Rio

Checking rocks.nvim config ~
- OK No errors found in config.

Checking rocks.toml ~
- OK No errors found in rocks.toml.

:checkhealth rocks-config

rocks-config: require("rocks-config.health").check()

Checking for errors while loading configs ~
- OK No configuration errors.

Checking for duplicate configuration files ~
- OK No duplicate configurations found.
jgregoire commented 1 month ago

I added require('rocks-config').configure('onedarkpro.nvim') to rocks_config.lua (called from init.lua)

rocks-config: require("rocks-config.health").check()

Checking for errors while loading configs ~
- ERROR Error while loading config 'onedarkpro.lua' for plugin 'onedarkpro.nvim'.
  - ADVICE:
    - Error was: /home/james/.config/nvim/lua/plugins//onedarkpro.lua:27: Vim:E919: Directory not found in 'packpath': "pack/*/opt/onedarkpro"

Checking for duplicate configuration files ~
- OK No duplicate configurations found.

"plugins//" eh?

I changed plugins_dir = 'plugins/' to plugins_dir = 'plugins', ran :Rocks sync, no change in behavior.

Finally I fixed packadd('onedarkpro') to packadd('onedarkpro.nvim') and things are working.

mrcjkb commented 1 month ago

Hey :wave:

Finally I fixed packadd('onedarkpro') to packadd('onedarkpro.nvim') and things are working.

packadd takes the package name, not the plugin's main Lua module name.

I added require('rocks-config').configure('onedarkpro.nvim') to rocks_config.lua (called from init.lua)

Since version 2, rocks-config.nvim no longer eagerly loads configs for opt plugins. This allows for interoperability with rocks-lazy.nvim.

Now there are two ways you can load the config for opt plugins:

[config]
plugins_dir = "plugins/"
load_opt_plugins = true
jgregoire commented 1 month ago

packadd takes the package name, not the plugin's main Lua module name.

Yeah, that was an error on my part.

I pushed my latest config. Colorscheme config is loading, but only if I call require('rocks-config').configure('onedarkpro.nvim')

legendary.nvim config is no longer being loaded. I haven't even touched that one. opt is not set.

mrcjkb commented 1 month ago

legendary.nvim config is no longer being loaded. I haven't even touched that one. opt is not set.

Have you confirmed that the config file is not being sourced with some debug prints?

I'm asking, because I just had a look at legendary.nvim, and found this in the readme:

  -- since legendary.nvim handles all your keymaps/commands,
  -- its recommended to load legendary.nvim before other plugins
  priority = 10000,

And looking at the source code, it appears that the setup function does more than just configuration.

I don't think supporting such manual initialisation logic with prioritisation should be within the scope of rocks(-config).nvim. If I understand this correctly, the legendary.setup() call would need to be invoked before you set any autocommands, keymaps, etc. in your init.lua. And in other cases, depending on other plugins being loaded before/after is simply a terrible anti pattern.

jgregoire commented 1 month ago

I added a vim.notify() to the beginning of each config file. I also :Rocks install lualine.nvim'd and added a config file for that.

The only config file that runs (and calls vim.notify) is onedarkpro.lua, which I have manually invoked with require('rocks-config').configure('onedarkpro.nvim')

I can call configure() on the other two plugins and then they work fine.

mrcjkb commented 1 month ago

This is probably not what's causing this problem for you, but I found an error in your config.

You have

vim.opt.runtimepath:append(vim.fs.joinpath(rocks_config.rocks_path, "lib", "luarocks", "rocks-5.1", "*", "*"))

in lua/rocks-config.lua (probably left over from the rocks.nvim version 1 installer).

It should be

vim.opt.runtimepath:append(vim.fs.joinpath(rocks_config.rocks_path, "lib", "luarocks", "rocks-5.1", "rocks.nvim", "*"))

I'll try and reproduce your issue later.

mrcjkb commented 1 month ago

Just reproduced it. Your rocks.nvim is out of date. And I guess rocks-config.nvim's rocks.nvim version constraint isn't correct (I'll fix that).

If you update rocks.nvim (:Rocks install rocks.nvim or :Rocks update to update all plugins), it should work.

jgregoire commented 1 month ago

Just reproduced it. Your rocks.nvim is out of date. And I guess rocks-config.nvim's rocks.nvim version constraint isn't correct (I'll fix that).

If you update rocks.nvim (:Rocks install rocks.nvim or :Rocks update to update all plugins), it should work.

Fixed the issue. Thanks!