Dein has hook_add hook_source etc. check the doc.packer has setup seems like hook_add. Add hoo_source is more better?
Could you explain the requested feature a bit more? I'm not sure I understand.
Packer currently has setup (code to run before a plugin is loaded) and config (code to run after a plugin is loaded) - do these do what you want?
I think setup same with hook_add. And config same with hook_source.
yes I already found it so I closed this issue. Don't mind. But another question. If custom package_root..the plugin doesn't loaded. @wbthomason
What path did you use for your custom package root? It must be on packpath - if it is, can you post your config so that I can try to replicate the issue? Thanks!
@wbthomason check here. a test code.
local M = {}
function M.load_repos()
local plugin_dir = os.getenv("HOME")..'/.cache/vim/plugins'
if vim.fn.has('vim_starting') then
vim.o.runtimepath = vim.o.runtimepath .. ','..plugin_dir ..'/packer.nvim'
end
local packer = require('packer')
local use = packer.use
packer.init({package_root = plugin_dir})
packer.reset()
use {'glepnir/dashboard-nvim'}
packer.install()
end
return M
Hmm. I don't believe that changes to runtimepath are also added to packpath. Could you try the following and tell me if you still have problems?
local M = {}
function M.load_repos()
local plugin_dir = os.getenv("HOME")..'/.cache/vim/plugins'
if vim.fn.has('vim_starting') then
vim.o.packpath = vim.o.packpath .. ','..plugin_dir
end
local packer = require('packer')
local use = packer.use
packer.init({package_root = plugin_dir})
packer.reset()
use 'glepnir/dashboard-nvim'
end
return M
I'll note that you also do not want to call packer.install() every time - that clones a plugin if it's missing. I've removed that line from your snippet.
@wbthomason just a test code . I know that.
@wbthomason no fix. check set packpath? has value.
Ok. I've played around with your example, and the problem is with the native packages feature rather than packer, I think.
If you're trying to do this in your .vimrc or init.vim, then the problem is that, with native packages, Neovim only sources files after sourcing your .vimrc. So, when you try to require('packer'), Neovim hasn't added its path to package.path (although, sidenote, manually modifying package.path isn't seeming to work either). You should instead try doing the packpath modification in your .vimrc and the rest of your packer code somewhere in plugin/.
I tried using your example with packer installed to somewhere on the packpath normally, and it works as expected - dashboard-nvim is installed to plugin_dir/pack/packer/start/dashboard-nvim. So, I think this is just issues with setting up your packpath.
This looks terrible. I don't use init.vim to manage configuration. All my configuration is under the lua file. I have to follow a fixed folder to make it work. I can make require ('packer') works. just add it to rtp. problem with load plugins dir..must be in packpath..
Unfortunately, I think that's just part of how the native packages feature works (which, I agree, is not ideal).
Does your use case work with other plugin managers based around native packages? If so, then it may be a packer bug.
Yes. It can works with dein.
dein.vim doesn't use native package features.
So it works.
Yes, as @Shougo said, dein isn't based on native packages.
yep. so i want to know does packer will be support?
packer already supports custom package_root values in my testing - the problem with your example is that your plugin_dir doesn't adhere to the structure required by the native packages feature.
The following snippet works for your use case - note the changed path in packer.init. It is also necessary to modify package.path (you could get away modifying runtimepath if you prefer) to make packer load from this location that is not already on the packpath, because of some annoying strangeness with how native packages and Lua interact:
local plugin_dir = os.getenv("HOME")..'/.cache/vim/plugins'
vim.o.packpath = vim.o.packpath .. ',' .. plugin_dir
package.path = package.path .. ';' .. plugin_dir .. '/pack/packer/start/packer.nvim/lua/?.lua'
local packer = require('packer')
local use = packer.use
packer.init({package_root = plugin_dir .. '/pack'})
use 'glepnir/dashboard-nvim'
packer.install()
packer is based on native packages and will not be changing to support the more traditional rtp-manipulation-based approach to plugin management.
Hmm I didn't like the native pack path. It is wired. I would like manage all plugins and backup dir swap dir tags dir etc in one dir. so if packer will not support custom plugins dir outside pack path. no reason to use for me.
@glepnir: I'm sorry, but I'm genuinely not sure what it is you want that packer doesn't already support? packer does support a custom plugins dir outside of the package path, as shown above - you just have to add that directory to your packpath, again, as shown.
Of course, you're free to use/not use whatever you like. Good luck either way!