zenbones-theme / zenbones.nvim

🪨 A collection of contrast-based Vim/Neovim colorschemes
MIT License
682 stars 48 forks source link

Cannot find function due to load order 'Unknown function: zenbones#setup_colorscheme' #50

Closed craigmac closed 2 years ago

craigmac commented 2 years ago

I use the Vim 8.2 native pack path, and have cloned this repo to ~./vim/pack/git/start/zenbones.nvim directory. The problem is that because of the runtime path load order rules, ~/.vim/pack/git/start/zenbones.nvim/colors/zenbones.vim is loaded before the ~/.vim/pack/git/start/zenbones.nvim/autoload/* files. So when starting up Vim I get the error that zenbones#setup_colorscheme is not defined (because at the time that colors/zenbones.vim is loaded the autoload files have not sourced yet). I discovered this by viewing the load order or scripts using :script. Can it be reworked so that a color file is not calling an autoload function?

mcchrish commented 2 years ago

I tested this out and can replicate. I also tested other colorschemes that uses autoload like everforest and onedark and see the same issue.

Meanwhile it works with vim-plug. In neovim it works with packer as well which just use native package manager under the hood.

Some work around that works:

  1. Call colorscheme zenbones in the after dir ~/.vim/after/plugin. Or
  2. Use the opt dir instead of start, then call packadd zenbones.nvim before calling colorscheme. This is actually what everforest recommends when using the builtin package manager: https://github.com/sainnhe/everforest/blob/becc25f317b23983fb9c422c7f22e0ac8e4b07a8/doc/everforest.txt#L46-L56.

I'm inclined this is a vim bug since vim-plug and neovim just works.

Onedark also recommend the same install as everforest: https://github.com/joshdick/onedark.vim#installation. Probably need to document it here as well.

craigmac commented 2 years ago

I wouldn't say it's a Vim bug, those authors are not following the way Vim runtimepath directories are documented to be sourced - they've went a different way which is fine, but that's on them. I've just copied the the zenbones_light.vim one I wanted into my colors directory and removed some of it's boilerplate to make it work.

ttchin commented 2 years ago

I have the same issue here and I got the problem after I updated zenbones.nvim three days ago. I'm not sure which commit induced this flaw.

mcchrish commented 2 years ago

For now look at the work around mentioned above or use v0.19 https://github.com/mcchrish/zenbones.nvim/releases/tag/v0.19.1 which is before the refactor was applied.

mcchrish commented 2 years ago

I got rid of autoload usage in latest main branch. Please confirm if it fixes the issue.

ttchin commented 2 years ago

I got rid of autoload usage in latest main branch. Please confirm if it fixes the issue.

Yes, it works now!

craigmac commented 2 years ago

Works!