Prevent nvim-tree From Polluting Jump Lists
Opened this issue · 2 comments
Hi, sorry to use black issue templete.
nvim-tree uses NvimTree_1 as default name, this will be keeped in jumplist,if it is openned by jumps picker, and save file. this will create a real file, and then open nvim-tree you will get this error:
"NvimTree_1" line 8 of 9 --88%-- col 7-5
"NvimTree_1" [New] --No lines in buffer--
"NvimTree_1" line 8 of 9 --88%-- col 7-5
"NvimTree_1" [New] --No lines in buffer--
"NvimTree_1" line 8 of 9 --88%-- col 7-5
"NvimTree_1" [New] --No lines in buffer--
"NvimTree_1" [New] 0L, 0B written
[NvimTree] Cannot rename C:\Users\wsdjeg\AppData\Local\nvim\init.lua -> C:\Users\wsdjeg\AppData\Local\nvim\init.lua: file already exists
Error executing Lua callback: ...undle_dir\nvim-tree\nvim-tree.lua/lua/nvim-tree/view.lua:104: Vim:E95: Buffer with this name already exists
stack traceback:
[C]: in function 'nvim_buf_set_name'
...undle_dir\nvim-tree\nvim-tree.lua/lua/nvim-tree/view.lua:104: in function 'create_buffer'
...undle_dir\nvim-tree\nvim-tree.lua/lua/nvim-tree/view.lua:292: in function 'open'
D:\bundle_dir\nvim-tree\nvim-tree.lua/lua/nvim-tree/lib.lua:34: in function 'open_view_and_draw'
D:\bundle_dir\nvim-tree\nvim-tree.lua/lua/nvim-tree/lib.lua:129: in function 'open'
...tree\nvim-tree.lua/lua/nvim-tree/actions/tree/toggle.lua:48: in function 'toggle'
...e_dir\nvim-tree\nvim-tree.lua/lua/nvim-tree/commands.lua:36: in function <...e_dir\nvim-tree\nvim-tree.lua/lua/nvim-tree/commands.lua:35>
is it possile to use empty buffer name?
Looking at how other plugins handle this:
- Telescope: uses
[Scratch]and[Prompt]buffers - fugitive: uses temporary blame buffers with a unique name e.g.
/tmp/nvim.alex/N0zPuK/3.fugitiveblamewhich come fromtempname() - gitsigns: similar to fugitive for diff buffers
There are a lot of cases in which nvim-tree uses the buffer name:
nvim-tree.lua/lua/nvim-tree/utils.lua
Lines 425 to 444 in e179ad2
I don't think we can safely use a scratch buffer or empty buffer name, as that has great potential to break things and will require a lot of work.
Using a tempname() buffer seems the safer course of action; however, that may break users who rely on the nvim-tree buffer name. I also prefer this as the user can still easily identify the nvim-tree buffers.
Recommendation:
- Make the changes to allow the use of a
tempnamebuffer - Add a new (default off) option to feature gate this, maybe
view.temp_buffer
As usual, pull requests are most gratefully appreciated, see