From 2d58095affa41bff8decc8cb486fa7b8e2e678d6 Mon Sep 17 00:00:00 2001 From: Alexander Courtis Date: Mon, 22 Aug 2022 15:58:08 +1000 Subject: [PATCH] fix(view): allow function for view.float.open_win_config --- doc/nvim-tree-lua.txt | 2 +- lua/nvim-tree/view.lua | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/doc/nvim-tree-lua.txt b/doc/nvim-tree-lua.txt index 4007a21d93c..59f923a227c 100644 --- a/doc/nvim-tree-lua.txt +++ b/doc/nvim-tree-lua.txt @@ -669,7 +669,7 @@ Window / buffer setup. *nvim-tree.view.float.open_win_config* Floating window config. See |nvim_open_win| for more details. - Type: `table`, Default: + Type: `table` or `function` that returns a table, Default: `{` `relative = "editor",` `border = "rounded",` diff --git a/lua/nvim-tree/view.lua b/lua/nvim-tree/view.lua index fb153de7b0d..f4970422461 100644 --- a/lua/nvim-tree/view.lua +++ b/lua/nvim-tree/view.lua @@ -133,9 +133,17 @@ local function set_window_options_and_buffer() 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() 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 a.nvim_command "vsp" M.reposition_window()