Add dir_up function to expose navigating up one directory

This commit is contained in:
Joel D. Elkins 2021-01-07 14:33:14 -06:00
parent 86944b51c0
commit cb2574728a
No known key found for this signature in database
GPG Key ID: 133589DC38921AE2

View File

@ -105,6 +105,19 @@ function M.on_keypress(mode)
end
end
function M.dir_up()
local node = lib.get_node_at_cursor()
if not node then
return lib.change_dir('..')
else
local newdir = vim.fn.fnamemodify(node.absolute_path, ':h')
if newdir == lib.Tree.cwd then
lib.change_dir('..')
end
lib.set_index_and_redraw(newdir)
end
end
function M.refresh()
lib.refresh_tree()
end