refacto: move some code into actions

(non breaking, old assignments link to new assignments)
- move lib.collapse-all into actions/collapse-all
- move lib.dir-up into actions/dir-up
- move lib.change-dir into actions/change-dir
- use setup option for change-dir global (and use the old option for
  setup)
This commit is contained in:
kiyan
2022-02-05 17:42:40 +01:00
parent 95e3aacc01
commit f74dd24c58
8 changed files with 107 additions and 57 deletions

View File

@@ -76,7 +76,7 @@ local keypress_funcs = {
next_sibling = require'nvim-tree.actions.movements'.sibling(1),
prev_git_item = go_to('prev_git_item'),
next_git_item = go_to('next_git_item'),
dir_up = lib.dir_up,
dir_up = require'nvim-tree.actions.dir-up'.fn,
close = function() require'nvim-tree'.close() end,
preview = function(node)
if node.name == '..' then
@@ -106,9 +106,9 @@ function M.on_keypress(action)
end
if node.name == ".." then
return lib.change_dir("..")
return require'nvim-tree.actions.change-dir'.fn("..")
elseif action == "cd" and node.entries ~= nil then
return lib.change_dir(lib.get_last_group_node(node).absolute_path)
return require'nvim-tree.actions.change-dir'.fn(lib.get_last_group_node(node).absolute_path)
elseif action == "cd" then
return
end