|
618 | 618 | ---@field split? "aboveleft"|"belowright"|"topleft"|"botright" Split modifier |
619 | 619 | ---@field tab? boolean Open the buffer in a new tab |
620 | 620 | ---@field close? boolean Close the original oil buffer once selection is made |
| 621 | +---@field handle_buffer_callback? fun(buf_id: integer) If defined, all other buffer related options here would be ignored. This callback allows you to take over the process of opening the buffer yourself. |
621 | 622 |
|
622 | 623 | ---Select the entry under the cursor |
623 | 624 | ---@param opts nil|oil.SelectOpts |
@@ -757,15 +758,19 @@ M.select = function(opts, callback) |
757 | 758 | elseif opts.split then |
758 | 759 | cmd = "sbuffer" |
759 | 760 | end |
760 | | - ---@diagnostic disable-next-line: param-type-mismatch |
761 | | - local ok, err = pcall(vim.cmd, { |
762 | | - cmd = cmd, |
763 | | - args = { filebufnr }, |
764 | | - mods = mods, |
765 | | - }) |
766 | | - -- Ignore swapfile errors |
767 | | - if not ok and err and not err:match("^Vim:E325:") then |
768 | | - vim.api.nvim_echo({ { err, "Error" } }, true, {}) |
| 761 | + if opts.handle_buffer_callback ~= nil then |
| 762 | + opts.handle_buffer_callback(filebufnr) |
| 763 | + else |
| 764 | + ---@diagnostic disable-next-line: param-type-mismatch |
| 765 | + local ok, err = pcall(vim.cmd, { |
| 766 | + cmd = cmd, |
| 767 | + args = { filebufnr }, |
| 768 | + mods = mods, |
| 769 | + }) |
| 770 | + -- Ignore swapfile errors |
| 771 | + if not ok and err and not err:match("^Vim:E325:") then |
| 772 | + vim.api.nvim_echo({ { err, "Error" } }, true, {}) |
| 773 | + end |
769 | 774 | end |
770 | 775 |
|
771 | 776 | open_next_entry(cb) |
|
0 commit comments