diff --git a/lua/oil/config.lua b/lua/oil/config.lua index 9102727d..9f7257e9 100644 --- a/lua/oil/config.lua +++ b/lua/oil/config.lua @@ -123,6 +123,8 @@ local default_config = { -- Configuration for the floating window in oil.open_float float = { -- Padding around the floating window + -- Accepts a number for padding to be the same on each side + -- OR a table with { horizontal = number, vertical = number } padding = 2, max_width = 0, max_height = 0, @@ -364,8 +366,12 @@ local M = {} ---@class (exact) oil.SetupProgressWindowConfig : oil.SetupWindowConfig ---@field minimized_border? string|string[] The border for the minimized progress window +---@class (exact) oil.FloatWindowPaddingConfig +---@field horizontal integer +---@field vertical integer + ---@class (exact) oil.FloatWindowConfig ----@field padding integer +---@field padding integer|oil.FloatWindowPaddingConfig ---@field max_width integer ---@field max_height integer ---@field border string|string[] @@ -427,6 +433,14 @@ M.setup = function(opts) new_conf.watch_for_changes = true end + -- If a number was given it is changed so no error is produced + if type(new_conf.float.padding) ~= "table" then + new_conf.float.padding = { + horizontal = new_conf.float.padding, + vertical = new_conf.float.padding + } + end + for k, v in pairs(new_conf) do M[k] = v end diff --git a/lua/oil/layout.lua b/lua/oil/layout.lua index 8ed7b4e6..460a8bcf 100644 --- a/lua/oil/layout.lua +++ b/lua/oil/layout.lua @@ -110,14 +110,14 @@ M.get_fullscreen_win_opts = function() local total_width = M.get_editor_width() local total_height = M.get_editor_height() - local width = total_width - 2 * config.float.padding + local width = total_width - 2 * config.float.padding.horizontal if config.float.border ~= "none" then width = width - 2 -- The border consumes 1 col on each side end if config.float.max_width > 0 then width = math.min(width, config.float.max_width) end - local height = total_height - 2 * config.float.padding + local height = total_height - 2 * config.float.padding.vertical if config.float.max_height > 0 then height = math.min(height, config.float.max_height) end