Closed SingularisArt closed 2 years ago
To do this you would have to manage vim's runtimepath
and packpath
. See the help for both runtimepath
and packpath
as they have a lot of detail explaining how vim finds and loads files.
Here is a quick example of setting up runtimepath
, packpath
, and packer
.
local sep = vim.loop.os_uname().sysname == 'Windows_NT' and [[\]] or [[/]]
local function join(...)
return table.concat({ ... }, sep)
end
local home = os.getenv 'HOME'
local len = #home
local homepath = join(home, '.config', 'config-name')
local cachepath = join(home, '.cache', 'config-name')
-- Add path locations for configuration
local rtp = { homepath, cachepath }
-- Add paths that dont start with home.
for _, p in ipairs(vim.opt.runtimepath:get()) do
if p:sub(1, len) ~= home then
rtp[#rtp + 1] = p
end
end
vim.opt.runtimepath = rtp
-- Packer paths and files
local pack_path = join(cachepath, 'site')
local package_root = join(pack_path, 'pack')
local compile_path = join(cachepath, 'plugin', 'packer_compiled.lua')
vim.g.loaded_remote_plugins = 1
vim.opt.packpath:prepend(pack_path)
local packer_bootstrap = false
local packer_install_path = join(package_root, 'packer', 'start', 'packer.nvim')
if vim.fn.isdirectory(packer_install_path) == 0 then
vim.fn.system { 'git', 'clone', 'https://github.com/wbthomason/packer.nvim', packer_install_path }
vim.cmd.packadd 'packer.nvim'
packer_bootstrap = true
end
require('packer').startup {
function(use)
use 'wbthomason/packer.nvim'
-- ...
if packer_bootstrap then
require('packer').sync()
end
end,
config = {
package_root = package_root,
compile_path = compile_path,
},
}
This isn't an issue, it's just a question.
I'm currently working on multiple NeoVim configurations at once, and I want to store each configuration's plugins in a different directory. How do I go about doing that? Also, on a different note, how can I have each configuration use a different cache directory as well?