I have created a minimal Neovim configuration (Test
) that only includes the plugin and the lazy.nvim setup.
The local neovim plugin Test
loads with lazy.nvim using Lazy-load on command: cmd = "Test"
.
After loading the command with :Test
, i get Command Test not found after loading test
.
This is the module:
local M = {}
function M.test()
local variable = vim.ui.input({ prompt = "Enter value: " }, function(str)
return str
end)
print(variable)
end
return M
This is the Lazy configuration:
local map_test = {
["<leader>T"] = {
mode = { "n" },
name = "Test",
["t"] = {
function()
require("test").test()
end,
"Test",
},
},
}
return {
name = "test",
cmd = "Test",
dir = "~/.config/nvim/lua/plugins-my/test.nvim",
config = function()
local wk = require("which-key")
wk.register(map_test)
end,
}
Added the structure of the lua directory as suggested by KamilCuk:
├── config
├── plugins-active
├── plugins-inactive
├── plugins-my
│ ├── motli.nvim
│ │ ├── lua
│ │ │ └── motli
│ │ └── plugin
│ ├── presenta.nvim
│ │ ├── lua
│ │ │ └── presenta
│ │ └── plugin
│ └── test.nvim
│ ├── lua
│ └── plugin
└── util
While the plugin is loaded and working, I wonder how to get around the message.
Thanks!
I have created a minimal Neovim configuration (Test
) that only includes the plugin and the lazy.nvim setup.
The local neovim plugin Test
loads with lazy.nvim using Lazy-load on command: cmd = "Test"
.
After loading the command with :Test
, i get Command Test not found after loading test
.
This is the module:
local M = {}
function M.test()
local variable = vim.ui.input({ prompt = "Enter value: " }, function(str)
return str
end)
print(variable)
end
return M
This is the Lazy configuration:
local map_test = {
["<leader>T"] = {
mode = { "n" },
name = "Test",
["t"] = {
function()
require("test").test()
end,
"Test",
},
},
}
return {
name = "test",
cmd = "Test",
dir = "~/.config/nvim/lua/plugins-my/test.nvim",
config = function()
local wk = require("which-key")
wk.register(map_test)
end,
}
Added the structure of the lua directory as suggested by KamilCuk:
├── config
├── plugins-active
├── plugins-inactive
├── plugins-my
│ ├── motli.nvim
│ │ ├── lua
│ │ │ └── motli
│ │ └── plugin
│ ├── presenta.nvim
│ │ ├── lua
│ │ │ └── presenta
│ │ └── plugin
│ └── test.nvim
│ ├── lua
│ └── plugin
└── util
While the plugin is loaded and working, I wonder how to get around the message.
Thanks!
Share Improve this question edited Mar 31 at 19:56 Mimosinnet asked Mar 31 at 18:37 MimosinnetMimosinnet 8855 silver badges10 bronze badges 3 |1 Answer
Reset to default 1As KamilCuk suggested, I needed to define the command Test
. Defining the command in the Lazy configuration solved the issue:
return {
name = "test",
cmd = "Test",
dir = "~/.config/nvim/lua/plugins-my/test.nvim",
config = function()
vim.api.nvim_create_user_command("Test", 'echo "Test plugin loaded"', {})
local wk = require("which-key")
wk.register(map_test)
end,
}
Thanks!
with :Test
where do you register :Test command? Where is the call tovim.api.nvim_create_user_command
? Tehre isrequire("test")
, but your dir is set to lua/plugins-my/test.nvim. So the path would berequire("plugins-my.test.nvim.test")
, but it is impossible to load a file with a dot, so rename it? What is the directory structure?This is the module:
isrequire("test")
working? Is your "Test" module loaded in:Lazy
? – KamilCuk Commented Mar 31 at 18:45vim.api.nvim_create_user_command
. I thought it was not needed, as the speccmd = "Test"
should Lazy-load the plugin (as it does). I will try your suggestion and include the directory structure to make the question clearer. Thanks very much for the suggestions! – Mimosinnet Commented Mar 31 at 19:50should Lazy-load the plugin
yes, it lazy loads the plugin and.. the command is still not found. You have to tell nvim the command. – KamilCuk Commented Mar 31 at 20:13