feat: allow window width resize

This commit is contained in:
jasilven
2020-10-21 08:49:00 +03:00
committed by Kiyan Yazdani
parent 85d4edc1c1
commit 87a4d60bbc

View File

@@ -17,6 +17,7 @@ M.Tree = {
buf_name = 'LuaTree', buf_name = 'LuaTree',
cwd = nil, cwd = nil,
win_width = vim.g.lua_tree_width or 30, win_width = vim.g.lua_tree_width or 30,
win_width_allow_resize = vim.g.lua_tree_width_allow_resize,
loaded = false, loaded = false,
bufnr = nil, bufnr = nil,
winnr = function() winnr = function()
@@ -195,10 +196,12 @@ function M.open_file(mode, filename)
end end
api.nvim_command(string.format("%s %s", mode, filename)) api.nvim_command(string.format("%s %s", mode, filename))
end end
local cur_win = api.nvim_get_current_win() if M.Tree.win_width_allow_resize ~= true then
M.win_focus() local cur_win = api.nvim_get_current_win()
api.nvim_command('vertical resize '..M.Tree.win_width) M.win_focus()
M.win_focus(cur_win) api.nvim_command('vertical resize '..M.Tree.win_width)
M.win_focus(cur_win)
end
if vim.g.lua_tree_quit_on_open then if vim.g.lua_tree_quit_on_open then
M.close() M.close()
end end