feat: add win_options to preview_win (#514)

This commit is contained in:
Micah Halter 2024-11-12 13:38:35 -05:00 committed by GitHub
parent c23fe08e05
commit bbeed86bde
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 12 additions and 0 deletions

View file

@ -143,6 +143,8 @@ local default_config = {
update_on_cursor_moved = true,
-- Maximum file size in megabytes to preview
max_file_size_mb = 100,
-- Window-local options to use for preview window buffers
win_options = {},
},
-- Configuration for the floating action confirmation window
confirmation = {
@ -326,12 +328,14 @@ local M = {}
---@class (exact) oil.PreviewWindowConfig
---@field update_on_cursor_moved boolean
---@field max_file_size_mb number
---@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 max_file_size_mb? number Maximum file size in megabytes to preview
---@field win_options? table<string, any> Window-local options to use for preview window buffers
---@class (exact) oil.SetupConfirmationWindowConfig : oil.SetupWindowConfig

View file

@ -551,6 +551,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

View file

@ -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