feature request: override entries
Did you check existing requests?
- [X] I have searched the existing issues
Describe the feature
I would like to edit the entry list displayed by Oil.
Provide background
I would like to provide additional information for certain directories and files. Ideally, via an autocmd/callback s.t. it isn't a burden to maintain on the Oil side.
What is the significance of this feature?
nice to have
Additional details
There are a couple of related issues that I've found but it seems that the go to recommendation is "use winbar" which wouldn't cut in my case. I've looked at the API, and while I can fetch lines from the Oil buffer, I couldn't find a supported way to edit them (and insert them back).
I understand that could break some core functionality but that's fine in my case.
I imagine there might be a way to do this.
You could look into defining a custom column, or set up some autocmds to add virtual text to the relevant lines
virtual text sounds good; do you have a suggestion what a good trigger would be? OilEnter is fine but afaik it would catch only the initial oil launch and not navigating to the parent dir? Is oil creating a new buffer when navigating up, or redrawing in the existing one?
You could check how this plugin is annotating the git status: https://github.com/refractalize/oil-git-status.nvim
I sorted it out using virtual text as recommended. An example for anyone who might come across this issue; it adds some virtual text on the first line:
vim.api.nvim_create_autocmd({ "User" }, {
pattern = { "OilEnter" },
callback = function()
local ns_id = vim.api.nvim_create_namespace("namespace")
local opts = {
id = 1,
virt_text = { { "some_text" } },
virt_text_pos = "eol",
}
vim.api.nvim_buf_clear_namespace(0, ns_id, 0, -1)
vim.api.nvim_buf_set_extmark(0, ns_id, 0, 0, opts)
end,
})
To me, it doesn't seem like it makes sense to implement it in oil directly but we could add some examples to the docs. When I was browsing the issues, I've noticed many people asking for displaying CWD in the list of entries. It's trivial with virtual text.
Happy to open a PR on that if you think it'd be useful