diff --git a/lua/oil/config.lua b/lua/oil/config.lua index 31e25f2a..37b8d669 100644 --- a/lua/oil/config.lua +++ b/lua/oil/config.lua @@ -323,11 +323,13 @@ local M = {} ---@class (exact) oil.PreviewWindowConfig ---@field update_on_cursor_moved boolean +---@field win_options table ---@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 Window-local options to use for preview window buffers ---@class (exact) oil.SetupConfirmationWindowConfig : oil.SetupWindowConfig diff --git a/lua/oil/init.lua b/lua/oil/init.lua index 600ccc5e..e2f010f9 100644 --- a/lua/oil/init.lua +++ b/lua/oil/init.lua @@ -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 diff --git a/lua/oil/view.lua b/lua/oil/view.lua index da404a30..ddc5db3c 100644 --- a/lua/oil/view.lua +++ b/lua/oil/view.lua @@ -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