simpler way of temporarily disabling plugins
One of the worst things about neovim in general at the moment is that debugging issues with plugins is a nightmare. Far too often I have to disable a couple of them to do this. Currently, to disable a plugin, I have to insert a disable=true and call PackerSync. This is not that big a deal, but because debugging is already so frustrating, it would make life slightly easier if I didn't have to constantly be calling PackerSync, removing directories, and re-cloning them. Perhaps there is already some way of making this easier that I'm missing?
@ExpandingMan you can also use cond = false (you might need to cross-check if cond is a boolean or a function), but that way it will not load a plugin, you'd need to run packer compile but should be fine afterwards
Thanks, that's certainly an improvement... however, for whatever reason, it appears that I must exit the session from which I called PackerCompile for this to work. Is there a way of improving on this?
@ExpandingMan this will be because the lua modules are loaded already so they need to be reloaded to catch the changes there is an autocommand in the README that explains how you can automatically reload your packer compiled file whenever the plugins config file changes which I think will help you here.
EDIT: woops @shadmansaleh is right, sorry I just default responded since the lua module is a common hang up but yeah if a plugin is already loaded there's no way to undo that as far as I know, although if it's lua based you can reload it's modules.
however, for whatever reason, it appears that I must exit the session from which I called PackerCompile for this to work.
There's no way to unload a plugin from a session. Once it's loaded it's loaded :D
Because plugin can have various kinds of sideeffects upon load. There's now way to reliably reverse them.
Usually what I do is if I'm debugging stuff like this is I edit packer config in one session and suspend it to open a new session then quit that and go back to previous session to further edit packer config if needed. You could try that :)
It seems I had an out-of-date line of code for updating automatically when plugins.lua is written. I have changed this to
vim.cmd([[
augroup packer_user_config
autocmd!
autocmd BufWritePost plugins.lua source <afile> | PackerCompile
augroup end
]])
as suggested in the readme.
New vim sessions now seem to respect the changes I have made. In plugins.lua.
I'm still having a problem with creating a minimal debugging config, however. I would like to be able to call nvim -u minimal.lua with a file
require("packer").startup(function()
use "module/to/test"
end)
However, this seems to be ignored even if I again call PackerCompile. Only calling PackerSync and deleting all plugins seems to resolve this.
How can I get packer to respect the configuration I provide in a minimal config?
@ExpandingMan I use the --noplugin flag and manually load the plugins I want to debug in the minimal.lua myself.
When you say "manually load the plugins", what do you mean?
I have tried nvim --noplugin -u minimal.lua but this doesn't work. For example
Packer = require("packer")
Packer.startup(function()
use "hrsh7th/nvim-cmp"
use "hrsh7th/cmp-buffer"
end)
I think the reason it doesn't work is because it can't load packer in the first place because I did --noplugin.
@ExpandingMan by manually load I mean that I use packadd directly and don't run minimal debug configs with packer e.g.
-- minimal.lua
vim.cmd [[packadd plugin.nvim]]
require('plugin_module').doThingImTesting()
Thanks, I think I'm almost there, but this is proving surprisingly frustrating. I'm setting up my nvim --noplugin -u minimal.lua by first using vim.cmd("set packpath="..dir) to set the path to the packer directory containing all plugins... however this does not work because packadd can seemingly only include packages from opt, while the packer packages are in start. I can't simply change the directory I point it to, because it expects a particular nesting structure. The only way I can see of getting around this would be creating symlinks, which is, you know, insane. Am I missing something?
You want --clean -u minimal.lua (at least on Neovim master). And the **/opt/* and **/start/* structure is hardcoded in Vim, I'm afraid. (For force-loading all start plugins, there's :packloadall.)
Has anyone found a simple way to turn plugins off and on quickly, to check for compatibility problems between them?
For me, changing from
use { "sainnhe/everforest" }
to
use { "sainnhe/everforest", cond = false }
(as suggested above) does not automatically disable the plugin, for some reason. Instead, I have to additionally run :PackerSync, which removes the directory on disk.
It would be great if there were a way to disable/re-enable a plugin without needing to change what's on disk.