Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: No easy way to add packs supplied with NeoVim, e.g. cfilter #214

Closed
3 tasks done
andrewferrier opened this issue Dec 28, 2022 · 7 comments · Fixed by #197
Closed
3 tasks done

bug: No easy way to add packs supplied with NeoVim, e.g. cfilter #214

andrewferrier opened this issue Dec 28, 2022 · 7 comments · Fixed by #197
Labels
bug Something isn't working

Comments

@andrewferrier
Copy link

Did you check docs and existing issues?

  • I have read all the lazy docs
  • I have searched the existing issues of lazy
  • I have searched the exsiting issues of the plugin I have a problem with

Neovim version (nvim -v)

0.8.1

Operating system/version

Arch Linux

Describe the bug

This is perhaps an error in my understanding, but it seems that because lazy.nvim wipes the packpath variable, there is no way to use the packadd command to use packages supplied with NeoVim. NeoVim these days supplies several 'plugins' as packages:

% ls ~/.local/share/nvenv/versions/0.8.1/share/nvim/runtime/pack/dist/opt/                                                            ~
cfilter/  justify/  matchit/  shellmenu/  swapmouse/  termdebug/  vimball/

Until I switched to NeoVim, I could use cfilter simply with vim.cmd.packadd('cfilter'), but once using lazy.nvim, that doesn't seem to be a choice any more.

For the record, for now I have worked around this with:

vim.cmd(
    "source "
        .. vim.env.VIMRUNTIME
        .. "/pack/dist/opt/cfilter/plugin/cfilter.vim"
)

I understand that it's your intention to have lazy.nvim control the startup process for performance reasons, but at the minimum I would suggest that this is an aspect where the workaround(s) (if one is needed and I've not misunderstood something) maybe need to be a little clearer. I read README.md and wasn't really clear on whether there was an "official" approach here.

Thanks for all your hard work on this fantastic new plugin manager!

Steps To Reproduce

  1. lazy.nvim config:
require("lazy").setup("lazy-plugin-spec", {
    lockfile = vim.fn.stdpath("state") .. "/lazy-lock.json",
    performance = {
        rtp = {
            disabled_plugins = {
                "2html",
                "gzip",
                "remote_plugins",
                "tarPlugin",
                "zipPlugin",

                -- These lines are needed to avoid opening directories from command line in
                -- netrw: https://github.com/elihunter173/dirbuf.nvim#notes
                "netrw",
                "netrwPlugin",
            },
        },
    },
    change_detection = {
        enabled = false,
        notify = false,
    },
})
  1. Try to run vim.cmd.packadd('cfilter') (or VimL equivalent)

  2. Get an error: E919: Directory not found in 'packpath': "pack/*/opt/cfilter"
    E919: Directory not found in 'packpath': "pack/*/opt/cfilter"

Expected Behavior

cfilter package can be added.

Repro

-- 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",
    "--single-branch",
    "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
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here

vim.cmd.packadd('cfilter')
@andrewferrier andrewferrier added the bug Something isn't working label Dec 28, 2022
@folke
Copy link
Owner

folke commented Dec 28, 2022

Just dont reset packpath then? Check the docs

@folke folke closed this as completed Dec 28, 2022
@andrewferrier
Copy link
Author

OK, so I do find it in the docs, and you're right, that does work. Sorry for missing it. I think that's not totally obvious default behavior though, essentially I think what's happening here is that we're prioritizing speed over correctness. Disabling NeoVim plugins out-of-the-box seems to me to violate the principle of least surprise. That's my take anyway - your call obviously. Thanks for the help.

@Chaitanyabsprip
Copy link

can we not just add cfilter to rtp in our configuration? I am facing the same issue, not being able to do packadd cfilter even after adding the directory to rtp.

@max397574
Copy link
Contributor

I think there should be no need to do packadd cfilter
adding it to runtimepath should be enough so you can use it

@folke folke reopened this Dec 29, 2022
@Chaitanyabsprip
Copy link

so I added the folder path to config.performance.rtp.paths and it worked! thanks.

@folke folke closed this as completed in db043da Dec 29, 2022
@folke
Copy link
Owner

folke commented Dec 29, 2022

You are right, that I should at least keep the vim runtime as part of the package path.

Just made that change.

This has zero performance impact to lazy, since lazy doesn't use packadd anyway.

@andrewferrier
Copy link
Author

@folke nice, good fix, this works! Thanks.

andrewferrier pushed a commit to andrewferrier/dotfiles that referenced this issue Dec 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants