I'm totally new to neovim. I already snap-installed neovim (Ubuntu) and I want now to install nvim-tree.
The documentation confuses me.
Here is my file .config/nvim/init.vim
call plug#begin(has('nvim') ? stdpath('data') . '/plugged' : '~/.vim/plugged')
Plug 'nvim-tree/nvim-tree.lua'
call plug#end()
Now calling :PlugInstall in neovim seems to install something.
But in the "Setup" part of the doc, it is said to add this in init.lua:
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1
vim.opt.termguicolors = true
require("nvim-tree").setup()
Since init.vim and init.lua are exclusive, I do not know what to do.
If I remove init.vim and create the file init.lua, I get this error:
E5113: Error while calling lua chunk: /home/laurent/.config/nvim/init.lua:4: module 'nvim-tree' not foun
d:
no field package.preload['nvim-tree']
no file './nvim-tree.lua'
no file '/build/nvim/parts/nvim/build/.deps/usr/share/luajit-2.1.0-beta3/nvim-tree.lua'
no file '/usr/local/share/lua/5.1/nvim-tree.lua'
no file '/usr/local/share/lua/5.1/nvim-tree/init.lua'
no file '/build/nvim/parts/nvim/build/.deps/usr/share/lua/5.1/nvim-tree.lua'
no file '/build/nvim/parts/nvim/build/.deps/usr/share/lua/5.1/nvim-tree/init.lua'
no file './nvim-tree.so'
no file '/usr/local/lib/lua/5.1/nvim-tree.so'
no file '/build/nvim/parts/nvim/build/.deps/usr/lib/lua/5.1/nvim-tree.so'
no file '/usr/local/lib/lua/5.1/loadall.so'
stack traceback:
[C]: in function 'require'
/home/laurent/.config/nvim/init.lua:4: in main chunk
QUESTIONS:
init.vim or init.lua (or is it a choice with no consequences ?)Answer to myself. It turns out that this works:
In ~/.config/nvim/init.vim:
call plug#begin(has('nvim') ? stdpath('data') . '/plugged' : '~/.vim/plugged')
Plug 'nvim-tree/nvim-tree.lua'
call plug#end()
lua << EOF
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1
vim.opt.termguicolors = true
require("nvim-tree").setup()
EOF
Then in neovim: :PlugInstall.
But I'm far from being sure that this is a good solution.
I ran into this same issue and found the following to be a cleaner solution:
init.lua file to something else (I used myinit.lua)source ~/.config/nvim/myinit.lua to the end of my init.vim file (alternatively you can use luafile instead of source)This way I can keep all the lua code contained to it's own file and don't have to use that ugly lua << EOF ... EOF syntax, but it's functionally equivalent anyway
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With