@@ -1177,23 +1177,32 @@ Setting your own mapping in the configuration will soon be deprecated, see |nvim
11771177
11781178The `list ` option in `view .mappings.list ` is a table of
11791179
1180- - `key ` can be either a string or a table of string (lhs)
1181- - `action` is the name of the action, set to `" " ` to remove default action
1182- - `action_cb` is the function that will be called, it receives the node as a parameter. Optional for default actions
1183- - `mode ` is normal by default
1180+ - `key ` (mandatory) string or a table of string
1181+ - `action` (mandatory) is the name of the action, set to `" " ` to remove default action, set to an arbitrary description when using `action_cb`
1182+ - `action_cb` (optional) is a custom function that will be called, it receives the node as a parameter.
1183+ - `mode ` (optional) is `n ` by default
1184+
1185+ Examples:
11841186>
1185- local tree_cb = require'nvim-tree.config'.nvim_tree_callback
1186-
1187- local function print_node_path(node) {
1188- print(node.absolute_path)
1189- }
1190-
1191- local list = {
1192- { key = {"<CR>", "o" }, action = "edit", mode = "n"},
1193- { key = "p", action = "print_path", action_cb = print_node_path },
1194- { key = "s", cb = tree_cb("vsplit") }, --tree_cb and the cb property are deprecated
1195- { key = "<2-RightMouse>", action = "" }, -- will remove default cd action
1196- }
1187+ local function print_node_path(node)
1188+ print(node.absolute_path)
1189+ end
1190+
1191+ ----
1192+
1193+ view = {
1194+ mappings = {
1195+ list = {
1196+ -- remove a default mapping for cd
1197+ { key = "<2-RightMouse>", action = "" }, -- will remove default cd action
1198+
1199+ -- add multiple normal mode mappings for edit
1200+ { key = { "<CR>", "o" }, action = "edit", mode = "n" },
1201+
1202+ -- custom action
1203+ { key = "p", action = "print_the_node_path", action_cb = print_node_path },
1204+
1205+ ----
11971206<
11981207Mouse support defined in | KeyBindings |
11991208
0 commit comments