chore: update documentation for tree mappings

This commit is contained in:
kiyan42
2021-03-06 12:49:30 +01:00
parent 1984c12510
commit 58e44d29d7
3 changed files with 97 additions and 38 deletions

View File

@@ -118,14 +118,40 @@ But you won't be able to map any keys from the setup with nvim_tree_bindings. Us
Default keybindings can be overriden. You can also define your own keymappings for the tree view:
```vim
lua <<EOF
local tree_cb = require'nvim-tree.config'.nvim_tree_callback
vim.g.nvim_tree_bindings = {
["<CR>"] = ":YourVimFunction()<cr>",
["u"] = ":lua require'some_module'.some_function()<cr>",
-- default mappings
["<CR>"] = tree_cb("edit"),
["o"] = tree_cb("edit"),
["<2-LeftMouse>"] = tree_cb("edit"),
["<2-RightMouse>"] = tree_cb("cd"),
["<C-]>"] = tree_cb("cd"),
["<C-v>"] = tree_cb("vsplit"),
["<C-x>"] = tree_cb("split"),
["<C-t>"] = tree_cb("tabnew"),
["<BS>"] = tree_cb("close_node"),
["<S-CR>"] = tree_cb("close_node"),
["<Tab>"] = tree_cb("preview"),
["I"] = tree_cb("toggle_ignored"),
["H"] = tree_cb("toggle_dotfiles"),
["R"] = tree_cb("refresh"),
["a"] = tree_cb("create"),
["d"] = tree_cb("remove"),
["r"] = tree_cb("rename"),
["<C-r>"] = tree_cb("full_rename"),
["x"] = tree_cb("cut"),
["c"] = tree_cb("copy"),
["p"] = tree_cb("paste"),
["[c"] = tree_cb("prev_git_item"),
["]c"] = tree_cb("next_git_item"),
["-"] = tree_cb("dir_up"),
["q"] = tree_cb("close"),
}
EOF
```
You can check the default binding table in `nvim-tree/config.lua`, under the `get_bindings` function.
This basically maps the default keys to the `on_keypress` function with different string parameters.
All mappings are set in `normal mode`.
## Note