Skip to content

Commit

Permalink
fix: actions.preview accepts options (#497)
Browse files Browse the repository at this point in the history
* fix: pass opts to actions.preview

* add opts type to action.preview

* run generate.py script
  • Loading branch information
vex9z7 authored Oct 25, 2024
1 parent 28aca0c commit cca1631
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
6 changes: 6 additions & 0 deletions doc/oil.txt
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,12 @@ preview *actions.previe
Open the entry under the cursor in a preview window, or close the preview
window if already open

Parameters:
{horizontal} `boolean` Open the buffer in a horizontal split
{split} `"aboveleft"|"belowright"|"topleft"|"botright"` Split
modifier
{vertical} `boolean` Open the buffer in a vertical split

preview_scroll_down *actions.preview_scroll_down*
Scroll down in the preview window

Expand Down
18 changes: 16 additions & 2 deletions lua/oil/actions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,21 @@ M.select_tab = {

M.preview = {
desc = "Open the entry under the cursor in a preview window, or close the preview window if already open",
callback = function()
parameters = {
vertical = {
type = "boolean",
desc = "Open the buffer in a vertical split",
},
horizontal = {
type = "boolean",
desc = "Open the buffer in a horizontal split",
},
split = {
type = '"aboveleft"|"belowright"|"topleft"|"botright"',
desc = "Split modifier",
},
},
callback = function(opts)
local entry = oil.get_cursor_entry()
if not entry then
vim.notify("Could not find entry under cursor", vim.log.levels.ERROR)
Expand All @@ -88,7 +102,7 @@ M.preview = {
return
end
end
oil.open_preview()
oil.open_preview(opts)
end,
}

Expand Down

0 comments on commit cca1631

Please sign in to comment.