Skip to content

Commit

Permalink
feat: add win_options to preview_win
Browse files Browse the repository at this point in the history
  • Loading branch information
mehalter committed Nov 12, 2024
1 parent 50c4bd4 commit 9cebd6d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lua/oil/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -323,11 +323,13 @@ local M = {}

---@class (exact) oil.PreviewWindowConfig
---@field update_on_cursor_moved boolean
---@field win_options table<string, any>

---@class (exact) oil.ConfirmationWindowConfig : oil.WindowConfig

---@class (exact) oil.SetupPreviewWindowConfig
---@field update_on_cursor_moved? boolean Whether the preview window is automatically updated when the cursor is moved
---@field win_options? table<string, any> Window-local options to use for preview window buffers

---@class (exact) oil.SetupConfirmationWindowConfig : oil.SetupWindowConfig

Expand Down
3 changes: 3 additions & 0 deletions lua/oil/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,9 @@ M.open_preview = function(opts, callback)
end

vim.api.nvim_set_option_value("previewwindow", true, { scope = "local", win = 0 })
for k, v in pairs(config.preview_win.win_options) do
vim.api.nvim_set_option_value(k, v, { scope = "local", win = preview_win })
end
vim.w.oil_entry_id = entry.id
vim.w.oil_source_win = prev_win
if is_visual_mode then
Expand Down
5 changes: 5 additions & 0 deletions lua/oil/view.lua
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,11 @@ M.set_win_options = function()
for k, v in pairs(config.win_options) do
vim.api.nvim_set_option_value(k, v, { scope = "local", win = winid })
end
if vim.wo[winid].previewwindow then -- apply preview window options last
for k, v in pairs(config.preview_win.win_options) do
vim.api.nvim_set_option_value(k, v, { scope = "local", win = winid })
end
end
end

---Get a list of visible oil buffers and a list of hidden oil buffers
Expand Down

0 comments on commit 9cebd6d

Please sign in to comment.