@@ -495,7 +495,28 @@ M.open_file = function(state, path, open_cmd)
495495 -- TODO: make this configurable, see issue #43
496496 if is_neo_tree_window then
497497 -- Neo-tree must be the only window, restore it's status as a sidebar
498- local width = M .get_value (state , " window.width" , 40 , false )
498+ local default_width = 40
499+ local width = M .get_value (state , " window.width" , default_width , false )
500+ local available_width = vim .api .nvim_win_get_width (0 )
501+ if type (width ) == " string" then
502+ if string.sub (width , - 1 ) == " %" then
503+ width = tonumber (string.sub (width , 1 , # width - 1 )) / 100
504+ else
505+ width = tonumber (width )
506+ end
507+ width = math.floor (available_width * width )
508+ elseif type (width ) == " function" then
509+ width = width ()
510+ if type (width ) ~= " number" then
511+ width = default_width
512+ else
513+ width = math.floor (width )
514+ end
515+ elseif type (width ) == " number" then
516+ width = math.floor (width )
517+ else
518+ width = default_width
519+ end
499520 local nt = require (" neo-tree" )
500521 local split_command = " vsplit "
501522 -- respect window position in user config when Neo-tree is the only window
0 commit comments