Let's say we use the following init.lua file in ~/.config/nvim:
-- vim: expandtab:shiftwidth=2:tabstop=2:softtabstop=2
vim.cmd('set noundofile')
vim.cmd('set nowritebackup')
vim.cmd('set noswapfile')
vim.cmd('set nowritebackup')
vim.cmd('set clipboard=unnamed,unnamedplus')
vim.cmd('set wildignorecase')
vim.cmd('set ignorecase')
vim.cmd('set hidden')
Global = {
colorscheme = 'tokyonight'
}
local install_path = vim.fn.expand(vim.fn.stdpath('data') .. '/site/pack/packer/opt/packer.nvim')
if vim.fn.empty(vim.fn.glob(install_path)) > 0 then
vim.cmd('!git clone https://github.com/wbthomason/packer.nvim ' .. install_path)
end
vim.cmd([[packadd packer.nvim]])
require('packer').startup(
function(use)
use { 'wbthomason/packer.nvim', opt = true }
use {
'folke/tokyonight.nvim',
config = function()
-- Using the global variable here makes the generated packer_compile.vim try to use it as well
if Global.colorscheme == 'tokyonight' then
vim.cmd('colorscheme tokyonight')
end
end
}
end
)
If we use it in ~/.config/nvim/init.lua and run :PackerCompile, everything works (assuming there wasn't already a packer_compiled.vim created with some error), if we restart neovim, everything still works.
If we put it in ~/.config/nvim/plugin/init.lua, open neovim, run :PackerCompile, everything works (because the global variable was already set on startup), but if we restart neovim, packer breaks:
This happens because plugin/init.lua is loaded after packer_compiled.vim, packer_compiled.vim tries to use global "Global" and fails because it is only set in plugin/init.lua
Actual behavior
Packer breaks if packer_compiled.vim depends on lua files in stdpath('config')/plugin/ (in the example I used a global variable, but there may be other cases)
Expected behavior
Packer should work as usual when using lua files in stdpath('config')/plugin/ (this is possible with #14686)
Aditional context
"Fixing" #201 would probably fix this issue as well
nvim --version
: NVIM v0.5.0-dev+d09b8adgit --version
: git version 2.31.1Steps to reproduce
(these steps are also described here)
Let's say we use the following
init.lua
file in ~/.config/nvim:If we use it in
~/.config/nvim/init.lua
and run:PackerCompile
, everything works (assuming there wasn't already a packer_compiled.vim created with some error), if we restart neovim, everything still works.If we put it in
~/.config/nvim/plugin/init.lua
, open neovim, run:PackerCompile
, everything works (because the global variable was already set on startup), but if we restart neovim, packer breaks:This happens because
plugin/init.lua
is loaded afterpacker_compiled.vim
,packer_compiled.vim
tries to use global "Global" and fails because it is only set inplugin/init.lua
Actual behavior
Packer breaks if
packer_compiled.vim
depends on lua files instdpath('config')/plugin/
(in the example I used a global variable, but there may be other cases)Expected behavior
Packer should work as usual when using lua files in
stdpath('config')/plugin/
(this is possible with #14686)Aditional context
"Fixing" #201 would probably fix this issue as well