More actions for opening entry in Dirbuf
RnYi opened this issue · 2 comments
For example, I want to open a file in a new tab.
I've wanted to add something like this, so I guess this is my push to actually do it. Here's my thoughts.
Ideally, there would be another a new command :DirbufEnter
which would do the same thing that <Plug>(dirbuf_enter)
does currently but is compatible with :tab {cmd}
, :vertical {cmd}
, etc. This should handle your simple case of opening an entry in a new tab by creating something like
autocmd FileType dirbuf nnoremap <buffer> whatever <cmd>tab DirbufEnter<cr>
Then I would also provide a new function require("dirbuf").get_cursor_path()
which returns the current path under the cursor, which should handle more complicated use cases where you want to do something other than just opening a file.
This has been implemented on main
.
423b21f implements a require("dirbuf").get_cursor_path()
function exactly like I described in my earlier comment.
445ed8b adds a cmd
parameter to require("dirbuf").enter()
, which defaults to "edit". You can read :help dirbuf.enter()
for more docs, but the gist is you can pass alternative edit commands (e.g. "tabedit" or "split") to open things in new tabs, splits, etc. So your use case of opening in a new tab should look something like this
autocmd FileType dirbuf nnoremap <buffer> whatever <cmd>lua require'dirbuf'.enter('tabedit')<cr>
Aside: @megalithic you should be able to switch back to mainline dirbuf.nvim if you want. Thanks for the implementation idea :)