1

I use Neovim (v0.9.5) and lazy to manage my plugins. My current config structure is as follows:

├── init.lua ├── lazy-lock.json └── lua └── enrique ├── core │   ├── init.lua │   ├── keymaps.lua │   └── options.lua ├── lazy.lua └── plugins ├── ... ├── which-key.lua └── ... 

I am trying to set up keymaps using which-key. So I need to add the line:

local wk = require("which-key") 

According to this documentation

However as soon as I add such line, I get this error:

Error detected while processing /home/enrique/suse-eo/config/nvim/init.lua: E5113: Error while calling lua chunk: /home/enrique/.config/nvim/lua/enrique/core/keymaps.lua:6: module 'which-key' not found: no field package.preload['which-key'] no file './which-key.lua' no file '/usr/share/luajit-5_1-2.1.0-beta3/which-key.lua' no file '/usr/local/share/lua/5.1/which-key.lua' no file '/usr/local/share/lua/5.1/which-key/init.lua' no file '/usr/share/lua/5.1/which-key.lua' no file '/usr/share/lua/5.1/which-key/init.lua' no file './which-key.so' no file '/usr/local/lib/lua/5.1/which-key.so' no file '/usr/lib64/lua/5.1/which-key.so' no file '/usr/local/lib/lua/5.1/loadall.so' stack traceback: [C]: in function 'require' /home/enrique/.config/nvim/lua/enrique/core/keymaps.lua:6: in main chunk [C]: in function 'require' /home/enrique/.config/nvim/lua/enrique/core/init.lua:2: in main chunk [C]: in function 'require' /home/enrique/suse-eo/config/nvim/init.lua:1: in main chunk 

The only similar issue I've found is this. However I don't really understand the how to apply that solution to my case since I don't have a lua/config/ directory.

I really hope someone can help me! Thanks in advance!

2 Answers 2

0

Looking at your file structure I would do:

local wk = require("enrique/plugins/which-key") 

Remark: The root for lua importation is: ~/.config/nvim/lua

2
  • Thanks for responding and I'm sorry I forgot to mention I had already tried that but then I get an error whenever I try to add a new key map. E5113: Error while calling lua chunk: /home/enrique/.config/nvim/lua/enrique/core/keymaps.lua:14: attempt to call field 'add' (a nil value) I'm using the which-key example: ``` local wk = require("enrique/plugins/which-key") wk.add({ mode = { "n", "v" }, { "<leader>q", "<cmd>q<cr>", desc = "Quit" }, { "<leader>w", "<cmd>w<cr>", desc = "Write" }, }) ``` Commented Sep 10, 2024 at 14:50
  • I believe we need to know mire about your init.lua file, the keymap.lua file. It would be good if you could reduce you configuration to a minimum problematic config to demonstrate the problem and share it with us. I suspect that somehow keymap.lua make us if which key too early. Commented Sep 11, 2024 at 4:40
0

I have had the same issue just a few minutes ago. Somewhere in your import, you are using locale wk = require(which-key) before the plugin itself.

1
  • Thank you for writing an answer. Your post looks very similar to Vivian's answer. You might want to edit to make it unique. With sufficient reputation, you will be able to vote for answers that you find useful. It would also be helpful to explain how the line you mention causes the issue and how to solve it. Commented Oct 24, 2024 at 6:41

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.