Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

nvim-tree does notBufWinEnter when opening onVimEnter #2130

Closed
@Iron-E

Description

@Iron-E

Description

I am a maintainer forbarbar.nvim, and we have a feature that allows users to adjust theoffset of the tabline when a sidebar (such as nvim-tree) is open.

This works well most of the time, however, recentlya user reported that this does not work when using theOpen At Startup snippets from the wiki. Upon investigation, it appears that this is because nvim-tree does not emit aBufWinEnter event in this case. It is worth noting that when doing:NvimTreeToggle afterward, it does.

Neovim version

NVIM v0.9.0Build type: ReleaseLuaJIT 2.1.0-beta3

Operating system and version

6.2.10-arch1-1

nvim-tree version

48d53a5

Minimal config

vim.api.nvim_create_autocmd(  {'BufWinEnter','FileType','WinNew','WinResized','WinScrolled'},  {callback=function(event)vim.print(event)end})vim.opt.rtp:append(vim.fn.stdpath('data')..'/lazy/nvim-tree.lua')require'nvim-tree'.setup {}-- auto open nvim-tree when open neovimlocalfunctionopen_nvim_tree(data)-- buffer is a real file on the disklocalreal_file=vim.fn.filereadable(data.file)==1-- buffer is a [No Name]localno_name=data.file==''andvim.bo[data.buf].buftype==''-- only files pleaseifnotreal_fileandnotno_namethenreturnend-- open the tree but dont focus itrequire('nvim-tree.api').tree.toggle({focus=false })endvim.api.nvim_create_autocmd({'VimEnter'}, {callback=open_nvim_tree })

It also happens withtree.open

Steps to reproduce

  1. nvim --clean -u minimal.lua
  2. Observe that aBufWinEnter event is not printed on startup for theNvimTree buffer.

Expected behavior

It follows the event sequence that happens when executing:NvimTreeToggle after startup concludes:

{buf=2,event="FileType",file="NvimTree_1",id=14,match="NvimTree"}{buf=1,event="WinNew",file="",id=14,match=""}{buf=2,event="BufWinEnter",file="/home/iron-e/NvimTree_1",id=14,match="/home/iron-e/NvimTree_1"}

You can verify the above by using this snippet:

vim.opt.rtp:append(vim.fn.stdpath('data')..'/lazy/nvim-tree.lua')require'nvim-tree'.setup {}-- start listening to autocmds AFTER vim enter; reduces noisevim.api.nvim_create_autocmd('VimEnter', {callback=function()vim.api.nvim_create_autocmd(    {'BufWinEnter','FileType','WinNew','WinResized','WinScrolled'},    {callback=function(event)vim.print(event)end}  )end})

Then manually typing:NvimTreeToggle.

Actual behavior

{buf=1,event="BufWinEnter",file="",id=3,match=""}{buf=2,event="FileType",file="NvimTree_1",id=3,match="NvimTree"}-- no ButWinEnter for `buf = 2`

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp