ITADN

NvimTree_1 will hijack the window when close the buf

#3315Openchenjie199234 创建于 2026-04-09
bugOS Windows PowerShell
C
chenjie199234commented
### Description 1. OpenDir <img width="2337" height="1205" alt="Image" src="https://github.com/user-attachments/assets/ce7c6909-6a23-443b-a288-df02f82b06ab" /> 2. OpenFile <img width="2318" height="1182" alt="Image" src="https://github.com/user-attachments/assets/11a5fb77-a0f0-43bb-bdca-c3277c97cf76" /> 3. :lua vim.lsp.buf.definition() on fmt.Println the buf changed to ```print.go```,the ```scan.go``` buf is because of the lsp's diagnostic if without this,close the opened file main.go directly,everything works fine <img width="2312" height="1204" alt="Image" src="https://github.com/user-attachments/assets/404f78da-a4d6-4bc4-b004-80287a455f98" /> 4. :bw close the current buf here is the problem! the NvimTree_1 hijack the window we can see the main.go in the buf list,there has no prefix path,so the current buf already changed to the main.go <img width="2330" height="1206" alt="Image" src="https://github.com/user-attachments/assets/5853d1bf-eb87-41d1-a1b2-40558eaf755a" /> 5. :bn change to next buf <img width="2263" height="1198" alt="Image" src="https://github.com/user-attachments/assets/109b56ea-72d5-4639-86ec-043392aa9f84" /> ### Neovim version ```text NVIM v0.12.1 Build type: Release LuaJIT 2.1.1774638290 ``` ### Operating system and version windows 11 amd64 ### Windows variant windows terminal app with powershell ### nvim-tree version "nvim-tree.lua": { "branch": "master", "commit": "509962f21ab7289d8dcd28568af539be39a8c01e" } ### Clean room replication ```lua require('lazy').setup({ { 'kyazdani42/nvim-tree.lua', opts={ on_attach=function(bufnr) local api = require('nvim-tree.api') api.config.mappings.default_on_attach(bufnr) vim.keymap.del('n','f',{ buffer = bufnr }) vim.keymap.del('n','F',{ buffer = bufnr }) vim.keymap.del('n','q',{ buffer = bufnr }) vim.keymap.set('n','f',api.tree.toggle) vim.keymap.set('n','F',api.tree.toggle) -- <C-_> is <C-/> vim.keymap.set('n','<C-_>',function()api.tree.open();api.live_filter.start();end) vim.keymap.set('n','<M-/>',function()api.tree.open();api.live_filter.start();end) vim.keymap.set('n','?',api.tree.toggle_help) end, disable_netrw=true, hijack_netrw=true, hijack_unnamed_buffer_when_opening=true, prefer_startup_root=true, sync_root_with_cwd=true, reload_on_bufenter=true, respect_buf_cwd=true, update_focused_file = { enable = true, update_root = { enable = true, ignore_list = {}, }, exclude = false, }, diagnostics = { enable = true, show_on_dirs = false, show_on_open_dirs = true, icons = { hint = "H", info = "I", warning = "W", error = "E", }, }, }, lazy=false, }, }) ``` ### Steps to reproduce see the Description ### Expected behavior when close the buf created by lsp's definition,the NvimTree_1 will not hijack the window ### Actual behavior when close the buf created by lsp's definition,the NvimTree_1 will hijack the window see the step 4
3 条评论