Skip to content

Error on 1st time running NvimTreeToggle (lazy load on command) #965

Closed
@folliehiyuki

Description

@folliehiyuki

OS
Alpine Linux (edge)

Neovim version

NVIM v0.6.1
Build type: MinSizeRel
LuaJIT 2.1.0-beta3
Compiled by buildozer@build-edge-x86_64

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/share/nvim"

Run :checkhealth for more info

Nvim-tree version
Latest commit from master branch

Describe the bug
nvim-tree errors out on 1st run with command NvimTreeToggle.
Using NvimTreeOpen works fine.
If update_cwd = false, nvim-tree will error out on closing the tree buffer the 1st time.

To Reproduce

  1. Lazy load nvim-tree with this config:
use {
  'kyazdani42/nvim-tree.lua',
  requires = 'kyazdani42/nvim-web-devicons',
  cmd = {'NvimTreeToggle', 'NvimTreeOpen'},
  config = function()
    require('nvim-tree').setup {
      update_focused_file = {enable = true, update_cwd = true}
    }
  end
}
  1. Start Neovim, and run command :NvimTreeToggle
  2. nvim-tree gives error:
E5108: Error executing lua ...vim/site/pack/packer/opt/packer.nvim/lua/packer/load.lua:165: Vim(echomsg)
:E114: Missing quote: "Error in packer_compiled: ...vim/site/pack/packer/opt/packer.nvim/lua/packer/load
.lua:83: Vim(lua):E5108: Error executing lua ...vim/site/pack/packer/opt/nvim-tree.lua/lua/nvim-tree.lua
:147: attempt to index global 'TreeExplorer' (a nil value)
stack traceback:
        [C]: in function 'cmd'
        ...vim/site/pack/packer/opt/packer.nvim/lua/packer/load.lua:165: in function <...vim/site/pack/p
acker/opt/packer.nvim/lua/packer/load.lua:161>
        [string ":lua"]:1: in main chunk

Expected behavior
NvimTree opens the buffer without any errors.

Additional context
Since NvimTreeOpen runs fine while NvimTreeToggle doesn't, the error clearly happens on https://github.com/kyazdani42/nvim-tree.lua/blob/c226eaf0bf09afedb5e9e2bda3c0bd4e8281a516/lua/nvim-tree.lua#L29-L31
but I don't know why.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions