folke / lazy.nvim

šŸ’¤ A modern plugin manager for Neovim
https://lazy.folke.io/
Apache License 2.0
14.88k stars 361 forks source link

Unable to import `plugins` from its `subfolders` #825

Closed ghost closed 1 year ago

ghost commented 1 year ago

Did you check docs and existing issues?

Neovim version (nvim -v)

0.9.0

Operating system/version

Ubuntu v23.04

Describe the bug

Error Message

Error detected while processing /home/swayam25/.config/nvim/init.lua:
E5113: Error while calling lua chunk: .../.local/share/nvim/lazy/lazy.nvim/lua/l
azy/core/util.lua:222: attempt to call method 'gsub' (a nil value)
stack traceback:
        .../.local/share/nvim/lazy/lazy.nvim/lua/lazy/core/util.lua:222: in func
tion 'get_unloaded_rtp'
        .../.local/share/nvim/lazy/lazy.nvim/lua/lazy/core/util.lua:246: in func
tion 'find_root'
        .../.local/share/nvim/lazy/lazy.nvim/lua/lazy/core/util.lua:258: in func
tion 'lsmod'
        ...local/share/nvim/lazy/lazy.nvim/lua/lazy/core/plugin.lua:275: in func
tion 'import'
        ...local/share/nvim/lazy/lazy.nvim/lua/lazy/core/plugin.lua:250: in func
tion 'normalize'
        ...local/share/nvim/lazy/lazy.nvim/lua/lazy/core/plugin.lua:238: in func
tion 'normalize'
        ...local/share/nvim/lazy/lazy.nvim/lua/lazy/core/plugin.lua:35: in funct
ion 'parse'
        ...local/share/nvim/lazy/lazy.nvim/lua/lazy/core/plugin.lua:395: in func
tion 'load'
        ...local/share/nvim/lazy/lazy.nvim/lua/lazy/core/loader.lua:36: in funct
ion 'setup'
        ...yam25/.local/share/nvim/lazy/lazy.nvim/lua/lazy/init.lua:75: in funct
ion 'setup'
        /home/swayam25/.config/nvim/lua/plugins/init.lua:18: in main chunk
        [C]: in function 'require'
        /home/swayam25/.config/nvim/init.lua:9: in main chunk

File Structure

.config/nvim
ā”œā”€ā”€ init.lua
ā”œā”€ā”€ lazy-lock.json
ā”œā”€ā”€ lua
ā”‚Ā Ā  ā”œā”€ā”€ autocmds.lua
ā”‚Ā Ā  ā”œā”€ā”€ keymaps.lua
ā”‚Ā Ā  ā”œā”€ā”€ options.lua
ā”‚Ā Ā  ā””ā”€ā”€ plugins
ā”‚Ā Ā      ā”œā”€ā”€ code
ā”‚Ā Ā      ā”‚Ā Ā  ā”œā”€ā”€ coc.lua
ā”‚Ā Ā      ā”‚Ā Ā  ā”œā”€ā”€ comment.lua
ā”‚Ā Ā      ā”‚Ā Ā  ā”œā”€ā”€ copilot.lua
ā”‚Ā Ā      ā”‚Ā Ā  ā”œā”€ā”€ luasnip.lua
ā”‚Ā Ā      ā”‚Ā Ā  ā”œā”€ā”€ nvim_cmp.lua
ā”‚Ā Ā      ā”‚Ā Ā  ā”œā”€ā”€ ultimate_autopair.lua
ā”‚Ā Ā      ā”‚Ā Ā  ā””ā”€ā”€ vim_illuminate.lua
ā”‚Ā Ā      ā”œā”€ā”€ init.lua
ā”‚Ā Ā      ā”œā”€ā”€ langs
ā”‚Ā Ā      ā”œā”€ā”€ ui
ā”‚Ā Ā      ā”‚Ā Ā  ā”œā”€ā”€ alpha.lua
ā”‚Ā Ā      ā”‚Ā Ā  ā”œā”€ā”€ bufferline.lua
ā”‚Ā Ā      ā”‚Ā Ā  ā”œā”€ā”€ catpuccin.lua
ā”‚Ā Ā      ā”‚Ā Ā  ā”œā”€ā”€ gitsigns.lua
ā”‚Ā Ā      ā”‚Ā Ā  ā”œā”€ā”€ mini_animate.lua
ā”‚Ā Ā      ā”‚Ā Ā  ā”œā”€ā”€ neoscroll.lua
ā”‚Ā Ā      ā”‚Ā Ā  ā”œā”€ā”€ neo_tree.lua
ā”‚Ā Ā      ā”‚Ā Ā  ā”œā”€ā”€ nvim_treesitter.lua
ā”‚Ā Ā      ā”‚Ā Ā  ā”œā”€ā”€ telescope.lua
ā”‚Ā Ā      ā”‚Ā Ā  ā”œā”€ā”€ vim_illuminate.lua
ā”‚Ā Ā      ā”‚Ā Ā  ā””ā”€ā”€ which_key.lua
ā”‚Ā Ā      ā””ā”€ā”€ version_control
ā”‚Ā Ā          ā””ā”€ā”€ lazygit.lua
ā””ā”€ā”€ stylua.toml

6 directories, 26 files

File: nvim/lua/plugins/init.lua

-- Vim.fn.stdpath("data") is in Linux systems: ~/.local/nvim
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"

-- If it's not found - indicating that it's not found - Git clone it (~)_(~)
if not vim.loop.fs_stat(lazypath) then
    -- Show a lovely message indicating that we're boostrapping lazy :)
    print("ļ„© Bootstrapping lazy.nvim!")

    --  lazy.nvim recommends to use vim.fn.system but, via `vim.cmd("!...")` we can know the progress ;)
    vim.cmd("!git clone --filter=blob:none https://github.com/folke/lazy.nvim.git --branch=stable " .. lazypath)
    print("ļ€Œ Done!")
end

-- Add it to RTP. So, we can require it later on
vim.opt.rtp:prepend(lazypath)

-- Import plugins from `lua/plugins`
require("lazy").setup(
    { 
        import = {
            "plugins.ui",
            "plugins.code",
            "plugins.langs",
            "plugins.version_control"
        }

    }, {
    defaults = {
        -- Lazy-load by default
        lazy = true,
        -- Use the latest version of the plugin (screw semantic versioning)
        version = false,
    },
    install = {
        -- Install missing plugins.
        missing = true,
        colorscheme = {
            -- These are a list of plugins to load when installing a plugin
            -- It's listed on order. catppuccin -> habamax
            "catppuccin",
            "habamax",
        },
    },
    performance = {
        rtp = {
            disabled_plugins = {
                -- I can disable more plugins such as `rplugin` and `netrw`, it'll decrease functionality.
                "gzip",
                "tarPlugin",
                "tohtml",
                "zipPlugin",
                "matchit",
                "matchparen",
                "netrwPlugin",
                "rplugin",
                "nvim",
                "tutor",
                -- "spellfile",
            },
        },
    },
})

File: nvim/init.lua

-- Enable the experimental new loader.
vim.loader.enable()

-- Set some options.
require("options")
require("autocmds")

-- Require lazy.nvim.
require("plugins")

-- Theme
vim.cmd.colorscheme("catpuccin")

vim.schedule(
    function()
        require("keymaps")
    end
)

Steps To Reproduce

Run nvim

Expected Behavior

It should load all the plugins with its subfolders

folke commented 1 year ago

You have nothing in langs?

ghost commented 1 year ago

You have nothing in langs?

No, langs folder is empty

folke commented 1 year ago

But you are importing it. So either put files in there or dont import it?

ghost commented 1 year ago

I tried by removing it from import, still it is showing the same error.

folke commented 1 year ago

https://github.com/folke/lazy.nvim#%EF%B8%8F-importing-specs-config--opts

import=... shoudl be a string, not a table

ghost commented 1 year ago

Can you please say how can I import all the plugins with its subfolders without any errors?

folke commented 1 year ago

Just add multiple imports.

{
  {import = "..."},
  {import = "..."},
}
ghost commented 1 year ago

Dear @folke ,

I would like to express my deepest gratitude for your exceptional support and expertise in resolving the issue I encountered with lazy.nvim. Your prompt response and diligent efforts in addressing my problem were truly remarkable.

Your in-depth knowledge and commitment to delivering a high-quality solution were evident throughout our interaction. Thanks to your guidance, I was able to overcome the obstacles I faced and continue leveraging the full potential of lazy.nvim in my projects.

I am sincerely grateful for your generosity in sharing your time and expertise. Your dedication to the open-source community is truly commendable, and it is developers like you who make the editors nvim a better place. Once again, thank you for your invaluable assistance.

With sincere appreciation, @Swayam25

folke commented 1 year ago

Thanks!