3

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:

  • Do I have to stick with init.vim or init.lua (or is it a choice with no consequences ?)
  • How do I install/use the plugin nvim-tree ?
Laurent Claessens
  • 547
  • 1
  • 3
  • 18

1 Answers1

3

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.

Laurent Claessens
  • 547
  • 1
  • 3
  • 18
  • as in the doc, it can also be installed with *packer*. then you only need `init.lua`. – pynexj Feb 13 '23 at 15:13
  • I have similar problem. My question is: did you give up `init.vim`? Because I have more configurations there and if possible, I would prefer to not move to Lua yet. – VictorHMartin Jul 23 '23 at 09:26
  • 1
    @VictorHMartin I continued like that with `init.vim`. When I need to add lua code, I put it in `lua << EOF ... EOF` and it works. As an example, I recently added ~30 lines of lua to configure [indent-blankline](https://github.com/lukas-reineke/indent-blankline.nvim) and it works perfectly well. – Laurent Claessens Jul 23 '23 at 09:37
  • @LaurentClaessens I've faced the same issue on my machine `ubuntu 22.04`, when I had my file named `init.lua`, but when I changed to `init.vim` it worked fine. I completely gave up on `nvim-tree` cuz it requires `.lua`, and switched to `preservim/nerdtree`. – Abdalla Abdalmunim Aug 21 '23 at 09:03