File tree Expand file tree Collapse file tree 3 files changed +25
-2
lines changed Expand file tree Collapse file tree 3 files changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -1233,4 +1233,12 @@ on_tree_close({handler})
1233
1233
{handler} `{function }` Handler function, with the
1234
1234
signature `function ()` .
1235
1235
1236
+ *nvim-tree.events.on_tree_resize()*
1237
+ on_tree_resize({handler} )
1238
+ Registers a handler for when NvimTree is resized.
1239
+
1240
+ Parameters: ~
1241
+ {handler} `{function }` Handler function, with the
1242
+ signature `function (size)` .
1243
+
1236
1244
vim:tw=78:ts=4:sw=4:et:ft=help:norl:
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ local Event = {
11
11
FileRemoved = " FileRemoved" ,
12
12
FolderCreated = " FolderCreated" ,
13
13
FolderRemoved = " FolderRemoved" ,
14
+ Resize = " Resize" ,
14
15
}
15
16
16
17
local function get_handlers (event_name )
@@ -72,6 +73,11 @@ function M._dispatch_on_tree_close()
72
73
dispatch (Event .TreeClose , nil )
73
74
end
74
75
76
+ -- @private
77
+ function M ._dispatch_on_tree_resize (size )
78
+ dispatch (Event .Resize , size )
79
+ end
80
+
75
81
-- Registers a handler for the Ready event.
76
82
-- @param handler (function) Handler with the signature `function()`
77
83
function M .on_nvim_tree_ready (handler )
@@ -126,4 +132,10 @@ function M.on_tree_close(handler)
126
132
register_handler (Event .TreeClose , handler )
127
133
end
128
134
135
+ -- Registers a handler for the Resize event.
136
+ -- @param handler (function) Handler with the signature function(size)
137
+ function M .on_tree_resize (handler )
138
+ register_handler (Event .Resize , handler )
139
+ end
140
+
129
141
return M
Original file line number Diff line number Diff line change @@ -244,12 +244,15 @@ function M.resize(size)
244
244
return
245
245
end
246
246
247
+ local new_size = get_size ()
247
248
if M .is_vertical () then
248
- a .nvim_win_set_width (M .get_winnr (), get_size () )
249
+ a .nvim_win_set_width (M .get_winnr (), new_size )
249
250
else
250
- a .nvim_win_set_height (M .get_winnr (), get_size () )
251
+ a .nvim_win_set_height (M .get_winnr (), new_size )
251
252
end
252
253
254
+ events ._dispatch_on_tree_resize (new_size )
255
+
253
256
if not M .View .preserve_window_proportions then
254
257
vim .cmd " :wincmd ="
255
258
end
You can’t perform that action at this time.
0 commit comments