Skip to content

Commit 1685484

Browse files
authored
doc: reinstate mapping doc, mark on_attach as experimental (#1481)
1 parent cfc4692 commit 1685484

File tree

2 files changed

+134
-53
lines changed

2 files changed

+134
-53
lines changed

doc/nvim-tree-lua.txt

Lines changed: 134 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,8 @@ Subsequent calls to setup will replace the previous configuration.
174174
sync_root_with_cwd = false,
175175
reload_on_bufenter = false,
176176
respect_buf_cwd = false,
177+
on_attach = "disable", -- function(bufnr). If nil, will use the deprecated mapping strategy
178+
remove_keymaps = false, -- boolean (disable totally or not) or list of key (lhs)
177179
view = {
178180
adaptive_size = false,
179181
centralize_selection = false,
@@ -628,11 +630,14 @@ Window / buffer setup.
628630
Configuration options for |nvim-tree-mappings|
629631

630632
*nvim-tree.view.mappings.custom_only*
631-
DEPRECATED: see |nvim-tree.remove_keymaps|
632-
633+
Will use only the provided user mappings and not the default otherwise,
634+
extends the default mappings with the provided user mappings.
635+
Type: `boolean`, Default: `false`
633636

634637
*nvim-tree.view.mappings.list*
635-
DEPRECATED: see |nvim-tree.on_attach|
638+
A list of keymaps that will extend or override the default keymaps.
639+
Type: `table`
640+
Default: see |nvim-tree-default-mappings|
636641

637642
*nvim-tree.renderer*
638643
UI rendering setup
@@ -1076,55 +1081,132 @@ exists.
10761081
==============================================================================
10771082
6. MAPPINGS *nvim-tree-mappings*
10781083

1079-
Setting your own mapping in the configuration is deprecated, see |nvim-tree.on_attach| now.
1080-
1081-
You can remove default mappings with |nvim-tree.remove_keymaps|.
1082-
1083-
`<CR>`, `o`, `<2-LeftMouse>` open a file or folder; root will cd to the above directory
1084-
`<C-e>` edit the file in place, effectively replacing the tree explorer
1085-
`O` same as (edit) with no window picker
1086-
`<C-]>`, `<2-RightMouse>` cd in the directory under the cursor
1087-
`<C-v>` open the file in a vertical split
1088-
`<C-x>` open the file in a horizontal split
1089-
`<C-t>` open the file in a new tab
1090-
`<` navigate to the previous sibling of current file/directory
1091-
`>` navigate to the next sibling of current file/directory
1092-
`P` move cursor to the parent directory
1093-
`<BS>` close current opened directory or parent
1094-
`<Tab>` open the file as a preview (keeps the cursor in the tree)
1095-
`K` navigate to the first sibling of current file/directory
1096-
`J` navigate to the last sibling of current file/directory
1097-
`I` toggle visibility of files/folders hidden via |git.ignore| option
1098-
`H` toggle visibility of dotfiles via |filters.dotfiles| option
1099-
`U` toggle visibility of files/folders hidden via |filters.custom| option
1100-
`R` refresh the tree
1101-
`a` add a file; leaving a trailing `/` will add a directory
1102-
`d` delete a file (will prompt for confirmation)
1103-
`D` trash a file via |trash| option
1104-
`r` rename a file
1105-
`<C-r>` rename a file and omit the filename on input
1106-
`x` add/remove file/directory to cut clipboard
1107-
`c` add/remove file/directory to copy clipboard
1108-
`p` paste from clipboard; cut clipboard has precedence over copy; will prompt for confirmation
1109-
`y` copy name to system clipboard
1110-
`Y` copy relative path to system clipboard
1111-
`gy` copy absolute path to system clipboard
1112-
`[e` go to next diagnostic item
1113-
`[c` go to next git item
1114-
`]e` go to prev diagnostic item
1115-
`]c` go to prev git item
1116-
`-` navigate up to the parent directory of the current file/directory
1117-
`s` open a file with default system application or a folder with default file manager, using |system_open| option
1118-
`f` live filter nodes dynamically based on regex matching.
1119-
`F` clear live filter
1120-
`q` close tree window
1121-
`W` collapse the whole tree
1122-
`E` expand the whole tree, stopping after expanding |actions.expand_all.max_folder_discovery| folders; this might hang neovim for a while if running on a big folder
1123-
`S` prompt the user to enter a path and then expands the tree to match the path
1124-
`.` enter vim command mode with the file the cursor is on
1125-
`<C-k>` toggle a popup with file infos about the file under the cursor
1126-
`g?` toggle help
1127-
`m` Toggle node in bookmarks
1084+
Setting your own mapping in the configuration will soon be deprecated, see |nvim-tree.on_attach| for experimental replacement.
1085+
1086+
The `list` option in `view.mappings.list` is a table of
1087+
1088+
- `key` can be either a string or a table of string (lhs)
1089+
- `action` is the name of the action, set to `""` to remove default action
1090+
- `action_cb` is the function that will be called, it receives the node as a parameter. Optional for default actions
1091+
- `mode` is normal by default
1092+
>
1093+
local tree_cb = require'nvim-tree.config'.nvim_tree_callback
1094+
1095+
local function print_node_path(node) {
1096+
print(node.absolute_path)
1097+
}
1098+
1099+
local list = {
1100+
{ key = {"<CR>", "o" }, action = "edit", mode = "n"},
1101+
{ key = "p", action = "print_path", action_cb = print_node_path },
1102+
{ key = "s", cb = tree_cb("vsplit") }, --tree_cb and the cb property are deprecated
1103+
{ key = "<2-RightMouse>", action = "" }, -- will remove default cd action
1104+
}
1105+
<
1106+
Mouse support defined in |KeyBindings|
1107+
1108+
DEFAULT MAPPINGS *nvim-tree-default-mappings*
1109+
1110+
`<CR>` edit open a file or folder; root will cd to the above directory
1111+
`o`
1112+
`<2-LeftMouse>`
1113+
`<C-e>` edit_in_place edit the file in place, effectively replacing the tree explorer
1114+
`O` edit_no_picker same as (edit) with no window picker
1115+
`<C-]>` cd cd in the directory under the cursor
1116+
`<2-RightMouse>`
1117+
`<C-v>` vsplit open the file in a vertical split
1118+
`<C-x>` split open the file in a horizontal split
1119+
`<C-t>` tabnew open the file in a new tab
1120+
`<` prev_sibling navigate to the previous sibling of current file/directory
1121+
`>` next_sibling navigate to the next sibling of current file/directory
1122+
`P` parent_node move cursor to the parent directory
1123+
`<BS>` close_node close current opened directory or parent
1124+
`<Tab>` preview open the file as a preview (keeps the cursor in the tree)
1125+
`K` first_sibling navigate to the first sibling of current file/directory
1126+
`J` last_sibling navigate to the last sibling of current file/directory
1127+
`I` toggle_git_ignored toggle visibility of files/folders hidden via |git.ignore| option
1128+
`H` toggle_dotfiles toggle visibility of dotfiles via |filters.dotfiles| option
1129+
`U` toggle_custom toggle visibility of files/folders hidden via |filters.custom| option
1130+
`R` refresh refresh the tree
1131+
`a` create add a file; leaving a trailing `/` will add a directory
1132+
`d` remove delete a file (will prompt for confirmation)
1133+
`D` trash trash a file via |trash| option
1134+
`r` rename rename a file
1135+
`<C-r>` full_rename rename a file and omit the filename on input
1136+
`x` cut add/remove file/directory to cut clipboard
1137+
`c` copy add/remove file/directory to copy clipboard
1138+
`p` paste paste from clipboard; cut clipboard has precedence over copy; will prompt for confirmation
1139+
`y` copy_name copy name to system clipboard
1140+
`Y` copy_path copy relative path to system clipboard
1141+
`gy` copy_absolute_path copy absolute path to system clipboard
1142+
`[e` prev_diag_item go to next diagnostic item
1143+
`[c` prev_git_item go to next git item
1144+
`]e` next_diag_item go to prev diagnostic item
1145+
`]c` next_git_item go to prev git item
1146+
`-` dir_up navigate up to the parent directory of the current file/directory
1147+
`s` system_open open a file with default system application or a folder with default file manager, using |system_open| option
1148+
`f` live_filter live filter nodes dynamically based on regex matching.
1149+
`F` clear_live_filter clear live filter
1150+
`q` close close tree window
1151+
`W` collapse_all collapse the whole tree
1152+
`E` expand_all expand the whole tree, stopping after expanding |actions.expand_all.max_folder_discovery| folders; this might hang neovim for a while if running on a big folder
1153+
`S` search_node prompt the user to enter a path and then expands the tree to match the path
1154+
`.` run_file_command enter vim command mode with the file the cursor is on
1155+
`<C-k>` toggle_file_info toggle a popup with file infos about the file under the cursor
1156+
`g?` toggle_help toggle help
1157+
`m` toggle_mark Toggle node in bookmarks
1158+
`bmv` bulk_move Move all bookmarked nodes into specified location
1159+
1160+
>
1161+
view.mappings.list = { -- BEGIN_DEFAULT_MAPPINGS
1162+
{ key = { "<CR>", "o", "<2-LeftMouse>" }, action = "edit" },
1163+
{ key = "<C-e>", action = "edit_in_place" },
1164+
{ key = "O", action = "edit_no_picker" },
1165+
{ key = { "<C-]>", "<2-RightMouse>" }, action = "cd" },
1166+
{ key = "<C-v>", action = "vsplit" },
1167+
{ key = "<C-x>", action = "split" },
1168+
{ key = "<C-t>", action = "tabnew" },
1169+
{ key = "<", action = "prev_sibling" },
1170+
{ key = ">", action = "next_sibling" },
1171+
{ key = "P", action = "parent_node" },
1172+
{ key = "<BS>", action = "close_node" },
1173+
{ key = "<Tab>", action = "preview" },
1174+
{ key = "K", action = "first_sibling" },
1175+
{ key = "J", action = "last_sibling" },
1176+
{ key = "I", action = "toggle_git_ignored" },
1177+
{ key = "H", action = "toggle_dotfiles" },
1178+
{ key = "U", action = "toggle_custom" },
1179+
{ key = "R", action = "refresh" },
1180+
{ key = "a", action = "create" },
1181+
{ key = "d", action = "remove" },
1182+
{ key = "D", action = "trash" },
1183+
{ key = "r", action = "rename" },
1184+
{ key = "<C-r>", action = "full_rename" },
1185+
{ key = "x", action = "cut" },
1186+
{ key = "c", action = "copy" },
1187+
{ key = "p", action = "paste" },
1188+
{ key = "y", action = "copy_name" },
1189+
{ key = "Y", action = "copy_path" },
1190+
{ key = "gy", action = "copy_absolute_path" },
1191+
{ key = "[e", action = "prev_diag_item" },
1192+
{ key = "[c", action = "prev_git_item" },
1193+
{ key = "]e", action = "next_diag_item" },
1194+
{ key = "]c", action = "next_git_item" },
1195+
{ key = "-", action = "dir_up" },
1196+
{ key = "s", action = "system_open" },
1197+
{ key = "f", action = "live_filter" },
1198+
{ key = "F", action = "clear_live_filter" },
1199+
{ key = "q", action = "close" },
1200+
{ key = "W", action = "collapse_all" },
1201+
{ key = "E", action = "expand_all" },
1202+
{ key = "S", action = "search_node" },
1203+
{ key = ".", action = "run_file_command" },
1204+
{ key = "<C-k>", action = "toggle_file_info" },
1205+
{ key = "g?", action = "toggle_help" },
1206+
{ key = "m", action = "toggle_mark" },
1207+
{ key = "bmv", action = "bulk_move" },
1208+
} -- END_DEFAULT_MAPPINGS
1209+
<
11281210

11291211
==============================================================================
11301212
7. HIGHLIGHT GROUPS *nvim-tree-highlight*

lua/nvim-tree.lua

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,6 @@ local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS
447447
number = false,
448448
relativenumber = false,
449449
signcolumn = "yes",
450-
-- @deprecated
451450
mappings = {
452451
custom_only = false,
453452
list = {

0 commit comments

Comments
 (0)