Skip to content

fix: bufnr is nil when incomplete setup #955

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

eightpigs
Copy link
Contributor

@eightpigs eightpigs commented Feb 9, 2022

bufnr is nil when opening quickly:

Vim(lua):E5108: Error executing lua ...nvim-tree.lua/lua/nvim-tree/view.lua:225: Expected Lua number
  stack traceback:
          [C]: in function 'nvim_buf_is_valid'
          ...e/pack/packer/start/nvim-tree.lua/lua/nvim-tree/view.lua:225: in function 'is_buf_valid'

Reproduce:

  1. Set keymap, eg: map <leader>1 :NvimTreeOpen<cr>
  2. Fast press: <leader>1 when nvim starting

@kyazdani42
Copy link
Member

i think i've made a few adjustments (monkey patches unfortunately) during the setup, is this still required on your end on latest master ?

@eightpigs
Copy link
Contributor Author

eightpigs commented Feb 10, 2022

i tested the latest master, the bug still exists:

E5108: Error executing lua /home/eightpigs/.config/nvim/helpers.lua:59: Vim(lua):E5108: Error executing lua ...te/pack/packer/start/nv
im-tree.lua/lua/nvim-tree/lib.lua:112: attempt to index global 'TreeExplorer' (a nil value)
stack traceback:
        ...te/pack/packer/start/nvim-tree.lua/lua/nvim-tree/lib.lua:112: in function 'open'
        ...m/site/pack/packer/start/nvim-tree.lua/lua/nvim-tree.lua:40: in function 'open'

The reason is:

open nvim-tree window(lib.lua#L105) before initialization is complete(delayed creation of buf and TreeExplorer: nvim-tree.lua#L386):

Solutions:

If the window is opening before the initialization is completed(nvim-tree.lua#L386 vim.schedule...), make it open in the next event loop.

So, I think my revision is still needed. 😆

Copy link
Member

@kyazdani42 kyazdani42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, this will be properly managed in a few weeks i hope.

@kyazdani42 kyazdani42 merged commit c226eaf into nvim-tree:master Feb 10, 2022
@folliehiyuki
Copy link
Contributor

Hi! I lazy-load nvim-tree.lua on NvimTreeOpen, NvimTreeToggle events. The command NvimTreeOpen works fine without issue after this commit.

Running NvimTreeToggle for the 1st time still gives me the 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.l
ua: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/packer/opt/packer.nvim/lua/packer/load.lua:161>
        [string ":lua"]:1: in main chunk

@kyazdani42
Copy link
Member

cannot reproduce, could you open an issue with your nvim-tree configuration ?

@folliehiyuki
Copy link
Contributor

Done. Issue #965 opened.

Almo7aya pushed a commit to Almo7aya/nvim-tree.lua that referenced this pull request Oct 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants