Closed qstrahl closed 9 months ago
Unfortunately this is probably not going to happen, and definitely not anytime soon. We need to still support the oil://
scheme because some people use oil in conjunction with other plugins (such as nvim-tree) that expect to own directory-named buffers. Since going with this design, it's been extremely helpful to be able to assume that all oil buffers start with a scheme. That assumption is now spread all throughout the code, and will be very difficult to track down and change all of them.
As a workaround, you can create a cabbr that makes it easier to run these sorts of commands in an oil buffer
vim.cmd.cabbr({ args = { "<expr>", "%", "&filetype == 'oil' ? bufname('%')[6:] : '%'" } })
You can also check out :help actions.open_cmdline
and :help actions.open_cmdline_dir
to create keymaps to quickly run a command on the current dir or file
I would also like to have this. I understand it's difficult however.
From a visual standpoint, there's options using a buffer-local winbar/statusline (similar to :h terminal-status
). Grepping could perhaps be helped with something like telescope.nvim and custom maps, unsure about git.
Roughly speaking, what all would be required to make this happen? On the concern of compatibility with things like nvim-tree, could it be made a opt-in config feature, for users that only use oil (assuming the underlying architecture could handle both approaches with minimal redundancy)
If you can give guidance on what would need to be done, I would consider looking into implementing it.
Miscellaneous ideas:
vim.b
) or custom buftype
(:h special-buffers
mentions a directory type, but it's unclear how to create/detect such a buffer)Though, since this kind of thing happens pretty often, maybe Neovim should grow a kind of 'logical buffer name' feature, which is used in buffer listings and things like % expansions, but not for things like autocmds. That would benefit a lot of plugins.
Did you check existing requests?
Describe the feature
Provide the option to not use the
oil://
scheme for buffers corresponding to local directories. For example, if I:edit ~/foo/
, the buffer name would just be~/foo/
rather thanoil:///home/qstrahl/foo/
.Provide background
With other similar plugins that don't add a custom scheme to directory paths, I can rely on the buffer name to correspond to the directory on disk. This allows for incidental seamless integration with other vim features, plugins, and command line tools.
For example, if the buffer name for
oil:///home/qstrahl/foo/
was instead~/foo/
, I could do things like:grep sometext %
or:Gedit %
or:!git log -- %
and it would all just work. Unfortunately, no other tools that I'm aware of know how to handle theoil://
scheme, so until support for it spreads to the likes ofgrep
andvim-fugitive
, this seems like the best way to ensure oil buffers are interoperable within the vim/commandline ecosystem.If there's some way to accomplish this already, I haven't been able to find it.
What is the significance of this feature?
strongly desired
Additional details
No response