Skip to content

Commit

Permalink
feat: add override config option to customize float layout (#132)
Browse files Browse the repository at this point in the history
* (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.
  • Loading branch information
aretrosen authored Jun 26, 2023
1 parent 4a4e0f4 commit ac72a8d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
5 changes: 5 additions & 0 deletions lua/oil/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
9 changes: 5 additions & 4 deletions lua/oil/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit ac72a8d

Please sign in to comment.