folke / lazy.nvim

💤 A modern plugin manager for Neovim
https://lazy.folke.io/
Apache License 2.0
15.07k stars 365 forks source link

bug: No errors shown if loading from dir= fails #1773

Open pinpox opened 1 month ago

pinpox commented 1 month ago

Did you check docs and existing issues?

Neovim version (nvim -v)

v0.10.1

Operating system/version

Nixos unstable

Describe the bug

When loading a plugin via the dir= directive, there is no error shown if this fails. The plugin will just silently not be there, instead of showing an error message.

Example plugin definition:

    {
        dir = pluginpaths .. "/outline.nvim",
        config = function()
            -- Example mapping to toggle outline
            vim.keymap.set("n", "<leader>o", "<cmd>Outline<CR>", { desc = "Toggle Outline" })

            require("outline").setup({
                -- Your setup opts here (leave empty to use defaults)
            })
        end,
    },

If for some reason (e.g. a typo) the path in dir= is missing outline.nvim it will just not load the plugin, without showing any errors.

Steps To Reproduce

Try to load non-existent plugin from dir=

Expected Behavior

A error is shown

Repro

vim.env.LAZY_STDPATH = ".repro"
load(vim.fn.system("curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))()

require("lazy.minit").repro({
  spec = {
     { dir = "/does/not/exist" }
  },
})
Drew-Daniels commented 3 weeks ago

This just got me too. Wasn't until I noticed that I had mistyped the path of a local plugin, that I realized lazy.nvim couldn't find my local package and wasn't throwing an error.

❯ uname -a
Darwin drews-m1-mbp 23.6.0 Darwin Kernel Version 23.6.0: Mon Jul 29 21:14:30 PDT 2024; root:xnu-10063.141.2~1/RELEASE_ARM64_T6000 arm64

❯ nvim -v
NVIM v0.10.2
Build type: Release
LuaJIT 2.1.1727870382
Run "nvim -V1 -v" for more info
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({
    "git",
    "clone",
    "--filter=blob:none",
    "https://github.com/folke/lazy.nvim.git",
    "--branch=stable", -- latest stable release
    lazypath,
  })
end
vim.opt.rtp:prepend(lazypath)

return require("lazy").setup({
  -- ...
  {
    "Exafunction/codeium.vim",
    event = "BufEnter",
    dir = "~/projects/codeium.vim", -- had typed codeium.vim instead of codeium.nvim
    -- dev = true,
  },
  -- ...
})