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

Sub modules not loading #66

Closed
B4rc1 opened this issue Dec 21, 2022 · 4 comments · Fixed by #55
Closed

Sub modules not loading #66

B4rc1 opened this issue Dec 21, 2022 · 4 comments · Fixed by #55
Labels
question Further information is requested

Comments

@B4rc1
Copy link

B4rc1 commented Dec 21, 2022

Hey, I tried migrating from packer to lazy. My current plugin structure is this.

In my init.lua i specify:

require("lazy").setup("plugins", { defaults = { version = "*" } })

The readme tells me:

any lua file in ~/.config/nvim/lua/plugins/*.lua will be automatically merged in the main plugin spec

But currently only the ~/.config/nvim/lua/plugins/init.lua file gets sourced and plugins installed from it. For example my fuzzy finder is neither loaded nor installed:
:lua require('fzf-lua').files():

E5108: Error executing lua [string ":lua"]:1: module 'fzf-lua' not found:
        no field package.preload['fzf-lua']
        no file '/nix/store/w08dyn0iamcixgc6cgv9ma8sq165vlvq-luajit-2.1.0-2022-10-04-env/share/lua/5.1/fzf-lua.lua'
        no file '/nix/store/w08dyn0iamcixgc6cgv9ma8sq165vlvq-luajit-2.1.0-2022-10-04-env/share/lua/5.1/fzf-lua/init.lua'
        no file '/nix/store/w08dyn0iamcixgc6cgv9ma8sq165vlvq-luajit-2.1.0-2022-10-04-env/lib/lua/5.1/fzf-lua.so'fzf-lua not found in lazy plugin
s
stack traceback:
        [C]: in function 'require'
        [string ":lua"]:1: in main chunk

What am I missing?

@folke
Copy link
Owner

folke commented Dec 21, 2022

I see you're using Nix. Might be related to that.
What gets printed if you execute the code below?

local Util = require("lazy.core.util")
Util.lsmod("plugins", function(modname, modpath)
  print(modname .. ": " .. modpath)
end)

@folke
Copy link
Owner

folke commented Dec 21, 2022

Is there anything else special about your Nix env I should know?
Lazy resets the rtp, so that might cause issues with Nix somehow. Try setting config.performane.rtp.reset = false

@folke folke added the question Further information is requested label Dec 21, 2022
@B4rc1
Copy link
Author

B4rc1 commented Dec 21, 2022

What gets printed if you execute the code below?

Nothing at all gets printed?! I tried inserting it into a file and running :so %, entering it into commandline like :lua require("lazy.core.util").lsmod("plugins", function(modname, modpath) print(modname .. ": " .. modpath) end) and inserting it into my init.lua

Is there anything else special about your Nix env I should know?

All my neovim config files are symlinks into the nix store (only the files, not the folders):

❯ ls -la .config/nvim
drwxr-xr-x    - jonas 21 Dez 16:14  ftplugin
drwxr-xr-x    - jonas 21 Dez 16:14  lua
lrwxrwxrwx   86 jonas 21 Dez 16:14  .gitignore -> /nix/store/3jwb4cc4r0yqgsyw16c611z03ssalrpw-home-manager-files/.config/nvim/.gitignore
lrwxrwxrwx   84 jonas 21 Dez 16:14  init.lua -> /nix/store/3jwb4cc4r0yqgsyw16c611z03ssalrpw-home-manager-files/.config/nvim/init.lua
.rw-r--r-- 4,2k jonas 21 Dez 13:37  lazy-lock.json

This also means, that all files are readonly from neovims perspective.

And I generate some paths to lspservers in nix and source them in neovim, this sould however not matter here.

Try setting config.performane.rtp.reset = false

Did not change a thing. Same problem

@folke
Copy link
Owner

folke commented Dec 21, 2022

gotcha. It's because they are links instead of files. Will change it so it works for links too

@folke folke closed this as completed in b7c489b Dec 21, 2022
KFearsoff added a commit to KFearsoff/home-manager that referenced this issue Sep 14, 2023
Currently, there are 5 packages that can be managed with Home Manager
that expose `finalPackage` option publicly: `pandoc`, `rofi`,
`timidity`, `emacs`, `hyprland`. This commit adds the 6th one: `neovim`.
While the final package that is being built after all of the
modifications should be considered an implementation detail, in cases of
complex software like `neovim` this could hide important details.

One particular case that comes to mind is using `lazy.nvim` package
manager. It exposes a number of useful APIs that really help managing
configuration, such as conditional keybindings, dependency tree
building, merging configurations, and so on. Questions about using it on
NixOS come up often, because manually recreating this functionality is
hard, and it's a very popular method of managing plugins that has good
UI/UX.

As it is now, it is impossible to use `lazy.nvim` with Nix efficiently.
`lazy.nvim` monopolizes the plugin management, which means that
installing plugins with Nix and managing them with `lazy.nvim` is not
supported. Some of the pitfalls are already described:
folke/lazy.nvim#402
folke/lazy.nvim#66

In short, to integrate `lazy.nvim` with Nix there are three things that
must be done:
1. `lazy.nvim` resets packpath, which should be managed by Nix; it has
   to be turned off with `performance.reset_packpath = false` option in
   `lazy.nvim`
2. Same thing applies to rtp, the relevant option is
   `performance.rtp.reset = false`
3. `dev.path` must be specified as the folder that contains the plugins.
   This folder is the path to Nix store path with Neovim plugins, and
   the plugins that are managed by Nix must be marked as `dev = true`
The third condition can not be fulfilled without this PR, as the final
package that Home Manager produces is not exposed, therefore it is
impossible to extract the Nix store path. This PR makes it possible to
be extracted via `${pkgs.vimUtils.packDir
config.home-manager.users.<user>.programs.neovim.finalPackage.passthru.packpathDirs}/pack/myNeovimPackages/start}`
expression.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants