norcalli / nvim-colorizer.lua

The fastest Neovim colorizer.
Other
2.25k stars 117 forks source link

runtimepath issue, colorizer.lua not found. #26

Closed bluz71 closed 4 years ago

bluz71 commented 4 years ago

Hello,

I have an ~/.config/nvim/init.vim with the following content:

set runtimepath^=~/.vim runtimepath+=~/.vim/after
let &packpath = &runtimepath
source ~/.vimrc

I do that since I want to share ~/.vimrc between Vim and Neovim.

In ~/.vimrc I have:

if empty(glob('~/.vim/autoload/plug.vim'))
  silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
    \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
  autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
call plug#begin('~/.vim/plugged')

if has("nvim")
Plug 'norcalli/nvim-colorizer.lua'
lua require'colorizer'.setup()
endif

call plug#end()

With that configuation, Neovim is failing to start with the following error:

no field package.preload['colorizer']
no file '/Users/bluz71/.vim/lua/colorizer.lua'
no file '/Users/bluz71/.vim/lua/colorizer/init.lua'
no file '/Users/bluz71/.config/nvim/lua/colorizer.lua'
no file '/Users/bluz71/.config/nvim/lua/colorizer/init.lua'
no file '/Users/bluz71/.local/share/nvim/site/lua/colorizer.lua'
no file '/Users/bluz71/.local/share/nvim/site/lua/colorizer/init.lua'

Ideally it should try and lookup /Users/bluz71/.vim/plugged/nvim-colorizer.lua/lua/colorizer.lua.

The &rtp does contain the path component /Users/bluz71/.vim/plugged/nvim-colorizer.lua/.

Is there something you should be doing at your end to extend lookup? Or is there something I need to do at my end?

Cheers.

norcalli commented 4 years ago

Put require 'colorizer.setup() after plug#end()

bluz71 commented 4 years ago

Thanks.

NilsIrl commented 4 years ago

I'm using vim's buitin package loader feature and it doesn't work.

packages seems to be loaded after the vimrc. (Which does make sense because other packages need the values set in the vimrc when they are loaded.)

The solution for me is to set nvim-colorizer.lua as an optional package (that needs to be manually loaded) and load it (using packadd) before calling lua require 'colorizer'.setup()

skbolton commented 4 years ago

The solution for me is to set nvim-colorizer.lua as an optional package (that needs to be manually loaded) and load it before calling lua require 'colorizer'.setup()

Thanks for this I was running into the same issue and this fixed it! @norcalli I am not good with the lua stuff in neovim - is there a way to lua require that would also look into the &packpath?