-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature request: ability to close oil buffer on select
action
#121
Comments
I've found a workaround for this: -- Helper function to close the oil buffer after a selection.
---@param select_opts table options to pass to `oil.select`
---@return function #function to invoke the action
local function select_close(select_opts)
return function()
local oil = require 'oil'
local oilwin = vim.api.nvim_get_current_win()
oil.select(select_opts)
vim.api.nvim_win_call(oilwin, function()
oil.close()
end)
end
end
require('oil').setup(
keymaps = {
['<C-s>'] = select_close { horizontal = true },
['<C-v>'] = select_close { vertical = true },
['<C-t>'] = select_close { tab = true },
}
) Feel free to close the issue if you think this feature isn't required in core :) |
I've added this as part of the core API. You can pass in |
Thanks! 😄 |
@stevearc i am struggeling to get it running. it would be nice to have one example in the docs on how to run a custom function for a keymap. how could it look like?
|
it will be
|
Did you check existing requests?
Describe the feature
When opening an entry in either split or a new tab, I want the oil buffer to close automatically.
Provide background
Most of the times whenever I'm opening an entry in some a new window or tab, I don't want the oil buffer to be around. I've to move to that window and close it.
An example workflow is that I'm working on 2 files and I opened the second one in a vertical split. The first file isn't visible as of now unless I quit the oil buffer manually. That requires moving to that window, closing the oil buffer and moving back to the second split.
Additional details
I thought something like this should work but it doesn't:
The text was updated successfully, but these errors were encountered: