Skip to content

Commit 3eb5e4c

Browse files
committed
chore(mappings): migrate legacy mappings under the hood: map keymap to legacy mappings
1 parent b4d8ef2 commit 3eb5e4c

File tree

3 files changed

+67
-54
lines changed

3 files changed

+67
-54
lines changed

lua/nvim-tree/keymap.lua

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ local DEFAULT_KEYMAPS = {
1111
long = "Open a file or directory; root will cd to the above directory.",
1212
short = "Open",
1313
},
14+
legacy_action = "edit",
1415
},
1516
{
1617
key = "<C-e>",
@@ -19,6 +20,7 @@ local DEFAULT_KEYMAPS = {
1920
long = "Open file in place, effectively replacing the tree explorer.",
2021
short = "Open: In Place",
2122
},
23+
legacy_action = "edit_in_place",
2224
},
2325
{
2426
key = "O",
@@ -27,6 +29,7 @@ local DEFAULT_KEYMAPS = {
2729
long = "Open file with no window picker.",
2830
short = "Open: No Window Picker",
2931
},
32+
legacy_action = "edit_no_picker",
3033
},
3134
{
3235
key = { "<C-]>", "<2-RightMouse>" },
@@ -35,6 +38,7 @@ local DEFAULT_KEYMAPS = {
3538
long = "cd in the directory under the cursor.",
3639
short = "CD",
3740
},
41+
legacy_action = "cd",
3842
},
3943
{
4044
-- key = "<C-v>",
@@ -44,6 +48,7 @@ local DEFAULT_KEYMAPS = {
4448
long = "Open file in a vertical split.",
4549
short = "Open: Vertical Split",
4650
},
51+
legacy_action = "vsplit",
4752
},
4853
{
4954
key = "<C-x>",
@@ -52,6 +57,7 @@ local DEFAULT_KEYMAPS = {
5257
long = "Open file in a horizontal split.",
5358
short = "Open: Horizontal Split",
5459
},
60+
legacy_action = "split",
5561
},
5662
{
5763
key = "<C-t>",
@@ -60,6 +66,7 @@ local DEFAULT_KEYMAPS = {
6066
long = "Open file in a new tab.",
6167
short = "Open: New Tab",
6268
},
69+
legacy_action = "tabnew",
6370
},
6471
{
6572
key = "<",
@@ -68,6 +75,7 @@ local DEFAULT_KEYMAPS = {
6875
long = "Navigate to the previous sibling.",
6976
short = "Previous Sibling",
7077
},
78+
legacy_action = "prev_sibling",
7179
},
7280
{
7381
key = ">",
@@ -76,6 +84,7 @@ local DEFAULT_KEYMAPS = {
7684
long = "Navigate to the next sibling",
7785
short = "Next Sibling",
7886
},
87+
legacy_action = "next_sibling",
7988
},
8089
{
8190
key = "P",
@@ -84,6 +93,7 @@ local DEFAULT_KEYMAPS = {
8493
long = "Move cursor to the parent directory.",
8594
short = "Parent Directory",
8695
},
96+
legacy_action = "parent_node",
8797
},
8898
{
8999
key = "<BS>",
@@ -92,6 +102,7 @@ local DEFAULT_KEYMAPS = {
92102
long = "Close current opened directory or parent.",
93103
short = "Close Directory",
94104
},
105+
legacy_action = "close_node",
95106
},
96107
{
97108
key = "<Tab>",
@@ -100,6 +111,7 @@ local DEFAULT_KEYMAPS = {
100111
long = "Open file as a preview (keeps the cursor in the tree).",
101112
short = "Open Preview",
102113
},
114+
legacy_action = "preview",
103115
},
104116
{
105117
key = "K",
@@ -108,6 +120,7 @@ local DEFAULT_KEYMAPS = {
108120
long = "Navigate to the first sibling.",
109121
short = "First Sibling",
110122
},
123+
legacy_action = "first_sibling",
111124
},
112125
{
113126
key = "J",
@@ -116,6 +129,7 @@ local DEFAULT_KEYMAPS = {
116129
long = "Navigate to the last sibling.",
117130
short = "Last Sibling",
118131
},
132+
legacy_action = "last_sibling",
119133
},
120134
{
121135
key = "I",
@@ -124,6 +138,7 @@ local DEFAULT_KEYMAPS = {
124138
long = "Toggle visibility of files/directories hidden via |git.ignore| option.",
125139
short = "Toggle Git Ignore",
126140
},
141+
legacy_action = "toggle_git_ignored",
127142
},
128143
{
129144
key = "H",
@@ -132,6 +147,7 @@ local DEFAULT_KEYMAPS = {
132147
long = "Toggle visibility of dotfiles via |filters.dotfiles| option.",
133148
short = "Toggle Dotfiles",
134149
},
150+
legacy_action = "toggle_dotfiles",
135151
},
136152
{
137153
key = "U",
@@ -140,6 +156,7 @@ local DEFAULT_KEYMAPS = {
140156
long = "Toggle visibility of files/directories hidden via |filters.custom| option.",
141157
short = "Toggle Hidden",
142158
},
159+
legacy_action = "toggle_custom",
143160
},
144161
{
145162
key = "R",
@@ -148,6 +165,7 @@ local DEFAULT_KEYMAPS = {
148165
long = "Refresh the tree.",
149166
short = "Refresh",
150167
},
168+
legacy_action = "refresh",
151169
},
152170
{
153171
key = "a",
@@ -156,6 +174,7 @@ local DEFAULT_KEYMAPS = {
156174
long = "Create a file; leaving a trailing `/` will add a directory.",
157175
short = "Create",
158176
},
177+
legacy_action = "create",
159178
},
160179
{
161180
key = "d",
@@ -164,6 +183,7 @@ local DEFAULT_KEYMAPS = {
164183
long = "Delete a file, prompting for confirmation.",
165184
short = "Delete",
166185
},
186+
legacy_action = "remove",
167187
},
168188
{
169189
key = "D",
@@ -172,6 +192,7 @@ local DEFAULT_KEYMAPS = {
172192
long = "Trash a file via |trash| option.",
173193
short = "Trash",
174194
},
195+
legacy_action = "trash",
175196
},
176197
{
177198
key = "r",
@@ -180,6 +201,7 @@ local DEFAULT_KEYMAPS = {
180201
long = "Rename a file or directory.",
181202
short = "Rename",
182203
},
204+
legacy_action = "rename",
183205
},
184206
{
185207
key = "<C-r>",
@@ -188,6 +210,7 @@ local DEFAULT_KEYMAPS = {
188210
long = "Rename a file or directory and omit the filename on input.",
189211
short = "Rename: Omit Filename",
190212
},
213+
legacy_action = "full_rename",
191214
},
192215
{
193216
key = "x",
@@ -196,6 +219,7 @@ local DEFAULT_KEYMAPS = {
196219
long = "Cut file or directory to cut clipboard.",
197220
short = "Cut",
198221
},
222+
legacy_action = "cut",
199223
},
200224
{
201225
key = "c",
@@ -204,6 +228,7 @@ local DEFAULT_KEYMAPS = {
204228
long = "Copy file or directory to copy clipboard.",
205229
short = "Copy",
206230
},
231+
legacy_action = "copy",
207232
},
208233
{
209234
key = "p",
@@ -212,6 +237,7 @@ local DEFAULT_KEYMAPS = {
212237
long = "Paste from clipboard; cut clipboard has precedence over copy; will prompt for confirmation.",
213238
short = "Paste",
214239
},
240+
legacy_action = "paste",
215241
},
216242
{
217243
key = "y",
@@ -220,6 +246,7 @@ local DEFAULT_KEYMAPS = {
220246
long = "Copy name to system clipboard.",
221247
short = "Copy Name",
222248
},
249+
legacy_action = "copy_name",
223250
},
224251
{
225252
key = "Y",
@@ -228,6 +255,7 @@ local DEFAULT_KEYMAPS = {
228255
long = "Copy relative path to system clipboard.",
229256
short = "Copy Relative Path",
230257
},
258+
legacy_action = "copy_path",
231259
},
232260
{
233261
key = "gy",
@@ -236,6 +264,7 @@ local DEFAULT_KEYMAPS = {
236264
long = "Copy absolute path to system clipboard.",
237265
short = "Copy Absolute Path",
238266
},
267+
legacy_action = "copy_absolute_path",
239268
},
240269
{
241270
key = "]e",
@@ -244,6 +273,7 @@ local DEFAULT_KEYMAPS = {
244273
long = "Go to next diagnostic item.",
245274
short = "Next Diagnostic",
246275
},
276+
legacy_action = "next_diag_item",
247277
},
248278
{
249279
key = "]c",
@@ -252,6 +282,7 @@ local DEFAULT_KEYMAPS = {
252282
long = "Go to next git item.",
253283
short = "Next Git",
254284
},
285+
legacy_action = "next_git_item",
255286
},
256287
{
257288
key = "[e",
@@ -260,6 +291,7 @@ local DEFAULT_KEYMAPS = {
260291
long = "Go to prev diagnostic item.",
261292
short = "Prev Diagnostic",
262293
},
294+
legacy_action = "prev_diag_item",
263295
},
264296
{
265297
key = "[c",
@@ -268,6 +300,7 @@ local DEFAULT_KEYMAPS = {
268300
long = "Go to prev git item.",
269301
short = "Prev Git",
270302
},
303+
legacy_action = "prev_git_item",
271304
},
272305
{
273306
key = "-",
@@ -276,6 +309,7 @@ local DEFAULT_KEYMAPS = {
276309
long = "Navigate up to the parent directory of the current file/directory.",
277310
short = "Up",
278311
},
312+
legacy_action = "dir_up",
279313
},
280314
{
281315
key = "s",
@@ -284,6 +318,7 @@ local DEFAULT_KEYMAPS = {
284318
long = "Open a file with default system application or a directory with default file manager, using |system_open| option.",
285319
short = "Run System",
286320
},
321+
legacy_action = "system_open",
287322
},
288323
{
289324
key = "f",
@@ -292,6 +327,7 @@ local DEFAULT_KEYMAPS = {
292327
long = "Live filter nodes dynamically based on regex matching.",
293328
short = "Filter",
294329
},
330+
legacy_action = "live_filter",
295331
},
296332
{
297333
key = "F",
@@ -300,6 +336,7 @@ local DEFAULT_KEYMAPS = {
300336
long = "Clear live filter.",
301337
short = "Clean Filter",
302338
},
339+
legacy_action = "clear_live_filter",
303340
},
304341
{
305342
key = "q",
@@ -308,6 +345,7 @@ local DEFAULT_KEYMAPS = {
308345
long = "Close tree window.",
309346
short = "Close",
310347
},
348+
legacy_action = "close",
311349
},
312350
{
313351
key = "W",
@@ -316,6 +354,7 @@ local DEFAULT_KEYMAPS = {
316354
long = "Collapse the whole tree.",
317355
short = "Collapse",
318356
},
357+
legacy_action = "collapse_all",
319358
},
320359
{
321360
key = "E",
@@ -324,6 +363,7 @@ local DEFAULT_KEYMAPS = {
324363
long = "Expand the whole tree, stopping after expanding |callbacks.expand_all.max_folder_discovery| directories; this might hang neovim for a while if running on a big directory.",
325364
short = "Expand All",
326365
},
366+
legacy_action = "expand_all",
327367
},
328368
{
329369
key = "S",
@@ -332,6 +372,7 @@ local DEFAULT_KEYMAPS = {
332372
long = "Prompt the user to enter a path and then expands the tree to match the path.",
333373
short = "Search",
334374
},
375+
legacy_action = "search_node",
335376
},
336377
{
337378
key = ".",
@@ -340,6 +381,7 @@ local DEFAULT_KEYMAPS = {
340381
long = "Enter vim command mode with the file the cursor is on.",
341382
short = "Run Command",
342383
},
384+
legacy_action = "run_file_command",
343385
},
344386
{
345387
key = "<C-k>",
@@ -348,6 +390,7 @@ local DEFAULT_KEYMAPS = {
348390
long = "Toggle a popup with file info about the file under the cursor.",
349391
short = "Info",
350392
},
393+
legacy_action = "toggle_file_info",
351394
},
352395
{
353396
key = "g?",
@@ -356,6 +399,7 @@ local DEFAULT_KEYMAPS = {
356399
long = "Toggle help.",
357400
short = "Help",
358401
},
402+
legacy_action = "toggle_help",
359403
},
360404
{
361405
key = "m",
@@ -364,6 +408,7 @@ local DEFAULT_KEYMAPS = {
364408
long = "Toggle node in bookmarks.",
365409
short = "Toggle Bookmark",
366410
},
411+
legacy_action = "toggle_mark",
367412
},
368413
{
369414
key = "bmv",
@@ -372,6 +417,7 @@ local DEFAULT_KEYMAPS = {
372417
long = "Move all bookmarked nodes into specified location.",
373418
short = "Move Bookmarked",
374419
},
420+
legacy_action = "bulk_move",
375421
},
376422
}
377423
-- END_DEFAULT_KEYMAPS

0 commit comments

Comments
 (0)