Move dir_up functionality into lib and make '-' a default keymap for it
This commit is contained in:
@@ -252,6 +252,7 @@ local function set_mappings()
|
||||
[bindings.paste] = 'on_keypress("paste")';
|
||||
[bindings.prev_git_item] = 'on_keypress("prev_git_item")';
|
||||
[bindings.next_git_item] = 'on_keypress("next_git_item")';
|
||||
[bindings.dir_up] = 'on_keypress("dir_up")';
|
||||
gx = "xdg_open()";
|
||||
}
|
||||
|
||||
@@ -366,4 +367,16 @@ function M.toggle_dotfiles()
|
||||
return M.refresh_tree()
|
||||
end
|
||||
|
||||
function M.dir_up(node)
|
||||
if not node then
|
||||
return M.change_dir('..')
|
||||
else
|
||||
local newdir = vim.fn.fnamemodify(node.absolute_path, ':h')
|
||||
if newdir == M.Tree.cwd then
|
||||
M.change_dir('..')
|
||||
end
|
||||
return M.set_index_and_redraw(newdir)
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
|
||||
Reference in New Issue
Block a user