Trouble using packer_plugins global #196
-
I'm trying to utilize the new For example, I only want to configure lightlines nvim-coc support if coc is actually installed: -- statusline.lua
[...]
if packer_plugins["coc-nvim"] and packer_plugins["coc-nvim"].loaded then
vim.fn['lightline#coc#register']()
end My config is structured into multiple files, so my init.lua (technically a start.lua in lua/ required in init.vim right now until I can move everything over to an actual init.lua) does this: require('plugins') -- contents as described in this projects README.md
require('statusline') This causes nvim to throw this error when starting up:
I'm new to lua and probably doing something very stupid here, but as far as I understand global variables should be available in another required file too. 🤷♂️ |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 7 replies
-
I think this is probably an issue regarding startup sourcing order. There are maybe two ways to deal with this. Option one is to move this code to a file in |
Beta Was this translation helpful? Give feedback.
I think this is probably an issue regarding startup sourcing order.
packer_compiled
is inplugin/
(by default), which gets sourced after yourinit.vim
. So, if you're doing these checks in yourinit.vim
,packer_plugins
doesn't exist yet. (you can see more on startup order with:help startup
)There are maybe two ways to deal with this. Option one is to move this code to a file in
plugin/
that gets sourced afterpacker_compiled
. Option two is to configurepacker
to put the compiled file somewhere else and manually source it in yourinit.vim
before you run this code.