From ac72a8df4afc1a543624c0eb1ebc0bedeb83c1a6 Mon Sep 17 00:00:00 2001 From: Aritra Sen <125266845+aretrosen@users.noreply.github.com> Date: Mon, 26 Jun 2023 21:26:22 +0530 Subject: [PATCH] feat: add override config option to customize float layout (#132) * (feat) Added override function for floatwin * (feat) Added in-place floatwin option modification Added in-place modification of floatwin options, and removed example from config.lua. --- lua/oil/config.lua | 5 +++++ lua/oil/init.lua | 9 +++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lua/oil/config.lua b/lua/oil/config.lua index 1b03875..305f377 100644 --- a/lua/oil/config.lua +++ b/lua/oil/config.lua @@ -80,6 +80,11 @@ local default_config = { win_options = { winblend = 10, }, + -- This is the config that will be passed to nvim_open_win. + -- Change values here to customize the layout + override = function(conf) + return conf + end, }, -- Configuration for the actions floating preview window preview = { diff --git a/lua/oil/init.lua b/lua/oil/init.lua index 9953075..f7b1f5a 100644 --- a/lua/oil/init.lua +++ b/lua/oil/init.lua @@ -271,6 +271,7 @@ M.open_float = function(dir) border = config.float.border, zindex = 45, } + win_opts = config.float.override(win_opts) or win_opts local winid = vim.api.nvim_open_win(bufnr, true, win_opts) vim.w[winid].is_oil_win = true @@ -323,10 +324,10 @@ M.open_float = function(dir) end vim.api.nvim_win_set_config(winid, { relative = "editor", - row = row, - col = col, - width = width, - height = height, + row = win_opts.row, + col = win_opts.col, + width = win_opts.width, + height = win_opts.height, title = get_title(), }) end,