folke / lazy.nvim

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

bug: Plugin nvim not found #1566

Closed hahuang65 closed 4 months ago

hahuang65 commented 4 months ago

Did you check docs and existing issues?

Neovim version (nvim -v)

NVIM v0.11.0-dev-313+gfc9b70826-Homebrew Build type: Release LuaJIT 2.1.1716656478

Operating system/version

macOS 14.3 (23D56)

Describe the bug

When I load a file into a buffer, I get a notification

2024-06-26T14:52:04 lazy.nvim  ERROR Plugin nvim not found

Steps To Reproduce

I open nvim and :e somefile.

Expected Behavior

No error. I wonder if it's a specific plugin that's having the error upon load. Is there a debug mode so I can see what Lazy is doing?

max397574 commented 4 months ago

likely because it's a dependency from a rockspec which gets parsed since 11.0 could you make sure you updated lazy and provide a minimal reproducible config?

folke commented 4 months ago

Can you also post the output of :checkhealth lazy? And make sure you don't have literally "nvim" somewhere in your specs

hahuang65 commented 4 months ago

Okay, it looks like the issue is folke/todo-comments.nvim. I have a file in lua/plugins/todo-comments.lua with the contents:

-- https://github.com/folke/todo-comments.nvim

return {
  "folke/todo-comments.nvim",
  event = { "BufReadPre", "BufNewFile" },
  dependencies = {
    "nvim-lua/plenary.nvim",
    "catppuccin/nvim",
  },
  keys = {
    {
      "]t",
      function()
        require("todo-comments").jump_next()
      end,
      desc = "Next todo comment",
    },
    {
      "[t",
      function()
        require("todo-comments").jump_prev()
      end,
      desc = "Previous todo comment",
    },
    { "<leader>st", ":TodoTelescope<CR>", desc = "[S]earch [T]ODOs" },
  },
  config = function()
    local C = require("catppuccin.palettes").get_palette()

    require("todo-comments").setup({
      signs = false,
      colors = {
        error = { "DiagnosticError", "ErrorMsg", C.red },
        warning = { "DiagnosticWarn", "WarningMsg", C.yellow },
        info = { "DiagnosticInfo", C.sapphire },
        hint = { "DiagnosticHint", C.green },
        default = { "Identifier", C.peach },
        test = { "Identifier", C.lavender },
      },
    })
  end,
}

If I simply remove this file from that directory such that Lazy doesn't load it... I don't have the error.

Strangely, when I try to put it in repro.lua:

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/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", lazypath })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "folke/tokyonight.nvim",
  -- add any other plugins here
  "nvim-lua/plenary.nvim",
  "catppuccin/nvim",
  "folke/todo-comments.nvim",
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

local C = require("catppuccin.palettes").get_palette()

require("todo-comments").setup({
  signs = false,
  colors = {
    error = { "DiagnosticError", "ErrorMsg", C.red },
    warning = { "DiagnosticWarn", "WarningMsg", C.yellow },
    info = { "DiagnosticInfo", C.sapphire },
    hint = { "DiagnosticHint", C.green },
    default = { "Identifier", C.peach },
    test = { "Identifier", C.lavender },
  },
})

vim.cmd.colorscheme("tokyonight")

I'm not able to reproduce the issue.

To answer your questions, I'm not familiar with luarocks or rockspec, and I'm certainly not intentionally using any luarocks.

I'm also not using any custom specs.

Finally, checkhealth lazy:

lazy: require("lazy.health").check()

lazy.nvim ~
- OK {git} `version 2.45.2`
- OK no existing packages found by other package managers
- OK packer_compiled.lua not found

luarocks ~
- checking `luarocks` installation
- OK no plugins require `luarocks`, so you can ignore any warnings below
- OK {luarocks} `/Users/hhhuang/.local/share/mise/installs/lua/5.1/luarocks/bin/luarocks 3.11.1`
- OK {lua} `Lua 5.1  Copyright (C) 1994-2006 Lua.org, PUC-Rio`
max397574 commented 4 months ago

@folke issue perhaps because of catpuccin/nvim and nvim is ignored because of neovim dependency in rockspecs? so having just nvim as repository name won't work?

hahuang65 commented 4 months ago

Possible, but I also have lua/plugins/catppuccin.lua whose contents are:

return {
  "catppuccin/nvim",
  name = "catppuccin",
  config = function()
    local catppuccin = require("catppuccin")
    vim.g.catppuccin_flavour = require("common").catppuccin_palette

    catppuccin.setup({
      compile = {
        enabled = true,
        path = vim.fn.stdpath("cache") .. "/catppuccin",
      },
      dim_inactive = {
        enabled = true,
        shade = "dark",
        percentage = 0.10,
      },
      transparent_background = false,
      term_colors = true,
      styles = {
        comments = { "italic" },
        functions = { "bold" },
        keywords = { "underline" },
        strings = {},
        variables = {},
      },
      integrations = {
        cmp = true,
        dap = {
          enabled = true,
          enable_ui = true,
        },
        fidget = true,
        gitsigns = true,
        indent_blankline = {
          enabled = true,
          colored_indent_levels = false,
        },
        mason = true,
        neotest = true,
        native_lsp = {
          enabled = true,
          virtual_text = {
            errors = { "bold", "italic" },
            hints = { "underline" },
            warnings = { "italic" },
            information = { "italic" },
          },
          underlines = {
            errors = { "underline" },
            hints = { "underline" },
            warnings = { "underline" },
            information = { "underline" },
          },
        },
        notify = true,
        octo = true,
        treesitter = true,
        treesitter_context = true,
        telescope = true,
      },
    })

    vim.cmd([[colorscheme catppuccin]])
    vim.api.nvim_set_hl(0, "CursorColumn", { link = "CursorLine" })
  end,
}

and this doesn't seem to cause any issues.

hahuang65 commented 4 months ago

@folke issue perhaps because of catpuccin/nvim and nvim is ignored because of neovim dependency in rockspecs? so having just nvim as repository name won't work?

Actually, this seems to be correct, but only in this case. My lua/plugins/catppuccin.lua file doesn't cause issues, but removing it as a dependency in lua/plugins/todo-comments.lua resolves the issue.

I wonder if it's specific to dependencies key.

folke commented 4 months ago

There's probably a bug in there indeed. Will look into it.

As for your dependencies, you don't need those. Lua deps are resolved automatically, so just remove them.