feat(view): allow function for view.float.open_win_config (#1538)

This commit is contained in:
Alexander Courtis
2022-08-23 17:14:23 +10:00
committed by GitHub
parent 259efeee62
commit c3ea264947
2 changed files with 10 additions and 2 deletions

View File

@@ -669,7 +669,7 @@ Window / buffer setup.
*nvim-tree.view.float.open_win_config* *nvim-tree.view.float.open_win_config*
Floating window config. See |nvim_open_win| for more details. Floating window config. See |nvim_open_win| for more details.
Type: `table`, Default: Type: `table` or `function` that returns a table, Default:
`{` `{`
`relative = "editor",` `relative = "editor",`
`border = "rounded",` `border = "rounded",`

View File

@@ -133,9 +133,17 @@ local function set_window_options_and_buffer()
end end
end end
local function open_win_config()
if type(M.View.float.open_win_config) == "function" then
return M.View.float.open_win_config()
else
return M.View.float.open_win_config
end
end
local function open_window() local function open_window()
if M.View.float.enable then if M.View.float.enable then
a.nvim_open_win(0, true, M.View.float.open_win_config) a.nvim_open_win(0, true, open_win_config())
else else
a.nvim_command "vsp" a.nvim_command "vsp"
M.reposition_window() M.reposition_window()