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.
This commit is contained in:
Aritra Sen 2023-06-26 21:26:22 +05:30 committed by GitHub
parent 4a4e0f4013
commit ac72a8df4a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 4 deletions

View file

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

View file

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