chore(mappings): migrate legacy mappings under the hood: map keymap to legacy mappings
This commit is contained in:
@@ -11,6 +11,7 @@ local DEFAULT_KEYMAPS = {
|
|||||||
long = "Open a file or directory; root will cd to the above directory.",
|
long = "Open a file or directory; root will cd to the above directory.",
|
||||||
short = "Open",
|
short = "Open",
|
||||||
},
|
},
|
||||||
|
legacy_action = "edit",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key = "<C-e>",
|
key = "<C-e>",
|
||||||
@@ -19,6 +20,7 @@ local DEFAULT_KEYMAPS = {
|
|||||||
long = "Open file in place, effectively replacing the tree explorer.",
|
long = "Open file in place, effectively replacing the tree explorer.",
|
||||||
short = "Open: In Place",
|
short = "Open: In Place",
|
||||||
},
|
},
|
||||||
|
legacy_action = "edit_in_place",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key = "O",
|
key = "O",
|
||||||
@@ -27,6 +29,7 @@ local DEFAULT_KEYMAPS = {
|
|||||||
long = "Open file with no window picker.",
|
long = "Open file with no window picker.",
|
||||||
short = "Open: No Window Picker",
|
short = "Open: No Window Picker",
|
||||||
},
|
},
|
||||||
|
legacy_action = "edit_no_picker",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key = { "<C-]>", "<2-RightMouse>" },
|
key = { "<C-]>", "<2-RightMouse>" },
|
||||||
@@ -35,6 +38,7 @@ local DEFAULT_KEYMAPS = {
|
|||||||
long = "cd in the directory under the cursor.",
|
long = "cd in the directory under the cursor.",
|
||||||
short = "CD",
|
short = "CD",
|
||||||
},
|
},
|
||||||
|
legacy_action = "cd",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
-- key = "<C-v>",
|
-- key = "<C-v>",
|
||||||
@@ -44,6 +48,7 @@ local DEFAULT_KEYMAPS = {
|
|||||||
long = "Open file in a vertical split.",
|
long = "Open file in a vertical split.",
|
||||||
short = "Open: Vertical Split",
|
short = "Open: Vertical Split",
|
||||||
},
|
},
|
||||||
|
legacy_action = "vsplit",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key = "<C-x>",
|
key = "<C-x>",
|
||||||
@@ -52,6 +57,7 @@ local DEFAULT_KEYMAPS = {
|
|||||||
long = "Open file in a horizontal split.",
|
long = "Open file in a horizontal split.",
|
||||||
short = "Open: Horizontal Split",
|
short = "Open: Horizontal Split",
|
||||||
},
|
},
|
||||||
|
legacy_action = "split",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key = "<C-t>",
|
key = "<C-t>",
|
||||||
@@ -60,6 +66,7 @@ local DEFAULT_KEYMAPS = {
|
|||||||
long = "Open file in a new tab.",
|
long = "Open file in a new tab.",
|
||||||
short = "Open: New Tab",
|
short = "Open: New Tab",
|
||||||
},
|
},
|
||||||
|
legacy_action = "tabnew",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key = "<",
|
key = "<",
|
||||||
@@ -68,6 +75,7 @@ local DEFAULT_KEYMAPS = {
|
|||||||
long = "Navigate to the previous sibling.",
|
long = "Navigate to the previous sibling.",
|
||||||
short = "Previous Sibling",
|
short = "Previous Sibling",
|
||||||
},
|
},
|
||||||
|
legacy_action = "prev_sibling",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key = ">",
|
key = ">",
|
||||||
@@ -76,6 +84,7 @@ local DEFAULT_KEYMAPS = {
|
|||||||
long = "Navigate to the next sibling",
|
long = "Navigate to the next sibling",
|
||||||
short = "Next Sibling",
|
short = "Next Sibling",
|
||||||
},
|
},
|
||||||
|
legacy_action = "next_sibling",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key = "P",
|
key = "P",
|
||||||
@@ -84,6 +93,7 @@ local DEFAULT_KEYMAPS = {
|
|||||||
long = "Move cursor to the parent directory.",
|
long = "Move cursor to the parent directory.",
|
||||||
short = "Parent Directory",
|
short = "Parent Directory",
|
||||||
},
|
},
|
||||||
|
legacy_action = "parent_node",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key = "<BS>",
|
key = "<BS>",
|
||||||
@@ -92,6 +102,7 @@ local DEFAULT_KEYMAPS = {
|
|||||||
long = "Close current opened directory or parent.",
|
long = "Close current opened directory or parent.",
|
||||||
short = "Close Directory",
|
short = "Close Directory",
|
||||||
},
|
},
|
||||||
|
legacy_action = "close_node",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key = "<Tab>",
|
key = "<Tab>",
|
||||||
@@ -100,6 +111,7 @@ local DEFAULT_KEYMAPS = {
|
|||||||
long = "Open file as a preview (keeps the cursor in the tree).",
|
long = "Open file as a preview (keeps the cursor in the tree).",
|
||||||
short = "Open Preview",
|
short = "Open Preview",
|
||||||
},
|
},
|
||||||
|
legacy_action = "preview",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key = "K",
|
key = "K",
|
||||||
@@ -108,6 +120,7 @@ local DEFAULT_KEYMAPS = {
|
|||||||
long = "Navigate to the first sibling.",
|
long = "Navigate to the first sibling.",
|
||||||
short = "First Sibling",
|
short = "First Sibling",
|
||||||
},
|
},
|
||||||
|
legacy_action = "first_sibling",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key = "J",
|
key = "J",
|
||||||
@@ -116,6 +129,7 @@ local DEFAULT_KEYMAPS = {
|
|||||||
long = "Navigate to the last sibling.",
|
long = "Navigate to the last sibling.",
|
||||||
short = "Last Sibling",
|
short = "Last Sibling",
|
||||||
},
|
},
|
||||||
|
legacy_action = "last_sibling",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key = "I",
|
key = "I",
|
||||||
@@ -124,6 +138,7 @@ local DEFAULT_KEYMAPS = {
|
|||||||
long = "Toggle visibility of files/directories hidden via |git.ignore| option.",
|
long = "Toggle visibility of files/directories hidden via |git.ignore| option.",
|
||||||
short = "Toggle Git Ignore",
|
short = "Toggle Git Ignore",
|
||||||
},
|
},
|
||||||
|
legacy_action = "toggle_git_ignored",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key = "H",
|
key = "H",
|
||||||
@@ -132,6 +147,7 @@ local DEFAULT_KEYMAPS = {
|
|||||||
long = "Toggle visibility of dotfiles via |filters.dotfiles| option.",
|
long = "Toggle visibility of dotfiles via |filters.dotfiles| option.",
|
||||||
short = "Toggle Dotfiles",
|
short = "Toggle Dotfiles",
|
||||||
},
|
},
|
||||||
|
legacy_action = "toggle_dotfiles",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key = "U",
|
key = "U",
|
||||||
@@ -140,6 +156,7 @@ local DEFAULT_KEYMAPS = {
|
|||||||
long = "Toggle visibility of files/directories hidden via |filters.custom| option.",
|
long = "Toggle visibility of files/directories hidden via |filters.custom| option.",
|
||||||
short = "Toggle Hidden",
|
short = "Toggle Hidden",
|
||||||
},
|
},
|
||||||
|
legacy_action = "toggle_custom",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key = "R",
|
key = "R",
|
||||||
@@ -148,6 +165,7 @@ local DEFAULT_KEYMAPS = {
|
|||||||
long = "Refresh the tree.",
|
long = "Refresh the tree.",
|
||||||
short = "Refresh",
|
short = "Refresh",
|
||||||
},
|
},
|
||||||
|
legacy_action = "refresh",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key = "a",
|
key = "a",
|
||||||
@@ -156,6 +174,7 @@ local DEFAULT_KEYMAPS = {
|
|||||||
long = "Create a file; leaving a trailing `/` will add a directory.",
|
long = "Create a file; leaving a trailing `/` will add a directory.",
|
||||||
short = "Create",
|
short = "Create",
|
||||||
},
|
},
|
||||||
|
legacy_action = "create",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key = "d",
|
key = "d",
|
||||||
@@ -164,6 +183,7 @@ local DEFAULT_KEYMAPS = {
|
|||||||
long = "Delete a file, prompting for confirmation.",
|
long = "Delete a file, prompting for confirmation.",
|
||||||
short = "Delete",
|
short = "Delete",
|
||||||
},
|
},
|
||||||
|
legacy_action = "remove",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key = "D",
|
key = "D",
|
||||||
@@ -172,6 +192,7 @@ local DEFAULT_KEYMAPS = {
|
|||||||
long = "Trash a file via |trash| option.",
|
long = "Trash a file via |trash| option.",
|
||||||
short = "Trash",
|
short = "Trash",
|
||||||
},
|
},
|
||||||
|
legacy_action = "trash",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key = "r",
|
key = "r",
|
||||||
@@ -180,6 +201,7 @@ local DEFAULT_KEYMAPS = {
|
|||||||
long = "Rename a file or directory.",
|
long = "Rename a file or directory.",
|
||||||
short = "Rename",
|
short = "Rename",
|
||||||
},
|
},
|
||||||
|
legacy_action = "rename",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key = "<C-r>",
|
key = "<C-r>",
|
||||||
@@ -188,6 +210,7 @@ local DEFAULT_KEYMAPS = {
|
|||||||
long = "Rename a file or directory and omit the filename on input.",
|
long = "Rename a file or directory and omit the filename on input.",
|
||||||
short = "Rename: Omit Filename",
|
short = "Rename: Omit Filename",
|
||||||
},
|
},
|
||||||
|
legacy_action = "full_rename",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key = "x",
|
key = "x",
|
||||||
@@ -196,6 +219,7 @@ local DEFAULT_KEYMAPS = {
|
|||||||
long = "Cut file or directory to cut clipboard.",
|
long = "Cut file or directory to cut clipboard.",
|
||||||
short = "Cut",
|
short = "Cut",
|
||||||
},
|
},
|
||||||
|
legacy_action = "cut",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key = "c",
|
key = "c",
|
||||||
@@ -204,6 +228,7 @@ local DEFAULT_KEYMAPS = {
|
|||||||
long = "Copy file or directory to copy clipboard.",
|
long = "Copy file or directory to copy clipboard.",
|
||||||
short = "Copy",
|
short = "Copy",
|
||||||
},
|
},
|
||||||
|
legacy_action = "copy",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key = "p",
|
key = "p",
|
||||||
@@ -212,6 +237,7 @@ local DEFAULT_KEYMAPS = {
|
|||||||
long = "Paste from clipboard; cut clipboard has precedence over copy; will prompt for confirmation.",
|
long = "Paste from clipboard; cut clipboard has precedence over copy; will prompt for confirmation.",
|
||||||
short = "Paste",
|
short = "Paste",
|
||||||
},
|
},
|
||||||
|
legacy_action = "paste",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key = "y",
|
key = "y",
|
||||||
@@ -220,6 +246,7 @@ local DEFAULT_KEYMAPS = {
|
|||||||
long = "Copy name to system clipboard.",
|
long = "Copy name to system clipboard.",
|
||||||
short = "Copy Name",
|
short = "Copy Name",
|
||||||
},
|
},
|
||||||
|
legacy_action = "copy_name",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key = "Y",
|
key = "Y",
|
||||||
@@ -228,6 +255,7 @@ local DEFAULT_KEYMAPS = {
|
|||||||
long = "Copy relative path to system clipboard.",
|
long = "Copy relative path to system clipboard.",
|
||||||
short = "Copy Relative Path",
|
short = "Copy Relative Path",
|
||||||
},
|
},
|
||||||
|
legacy_action = "copy_path",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key = "gy",
|
key = "gy",
|
||||||
@@ -236,6 +264,7 @@ local DEFAULT_KEYMAPS = {
|
|||||||
long = "Copy absolute path to system clipboard.",
|
long = "Copy absolute path to system clipboard.",
|
||||||
short = "Copy Absolute Path",
|
short = "Copy Absolute Path",
|
||||||
},
|
},
|
||||||
|
legacy_action = "copy_absolute_path",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key = "]e",
|
key = "]e",
|
||||||
@@ -244,6 +273,7 @@ local DEFAULT_KEYMAPS = {
|
|||||||
long = "Go to next diagnostic item.",
|
long = "Go to next diagnostic item.",
|
||||||
short = "Next Diagnostic",
|
short = "Next Diagnostic",
|
||||||
},
|
},
|
||||||
|
legacy_action = "next_diag_item",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key = "]c",
|
key = "]c",
|
||||||
@@ -252,6 +282,7 @@ local DEFAULT_KEYMAPS = {
|
|||||||
long = "Go to next git item.",
|
long = "Go to next git item.",
|
||||||
short = "Next Git",
|
short = "Next Git",
|
||||||
},
|
},
|
||||||
|
legacy_action = "next_git_item",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key = "[e",
|
key = "[e",
|
||||||
@@ -260,6 +291,7 @@ local DEFAULT_KEYMAPS = {
|
|||||||
long = "Go to prev diagnostic item.",
|
long = "Go to prev diagnostic item.",
|
||||||
short = "Prev Diagnostic",
|
short = "Prev Diagnostic",
|
||||||
},
|
},
|
||||||
|
legacy_action = "prev_diag_item",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key = "[c",
|
key = "[c",
|
||||||
@@ -268,6 +300,7 @@ local DEFAULT_KEYMAPS = {
|
|||||||
long = "Go to prev git item.",
|
long = "Go to prev git item.",
|
||||||
short = "Prev Git",
|
short = "Prev Git",
|
||||||
},
|
},
|
||||||
|
legacy_action = "prev_git_item",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key = "-",
|
key = "-",
|
||||||
@@ -276,6 +309,7 @@ local DEFAULT_KEYMAPS = {
|
|||||||
long = "Navigate up to the parent directory of the current file/directory.",
|
long = "Navigate up to the parent directory of the current file/directory.",
|
||||||
short = "Up",
|
short = "Up",
|
||||||
},
|
},
|
||||||
|
legacy_action = "dir_up",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key = "s",
|
key = "s",
|
||||||
@@ -284,6 +318,7 @@ local DEFAULT_KEYMAPS = {
|
|||||||
long = "Open a file with default system application or a directory with default file manager, using |system_open| option.",
|
long = "Open a file with default system application or a directory with default file manager, using |system_open| option.",
|
||||||
short = "Run System",
|
short = "Run System",
|
||||||
},
|
},
|
||||||
|
legacy_action = "system_open",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key = "f",
|
key = "f",
|
||||||
@@ -292,6 +327,7 @@ local DEFAULT_KEYMAPS = {
|
|||||||
long = "Live filter nodes dynamically based on regex matching.",
|
long = "Live filter nodes dynamically based on regex matching.",
|
||||||
short = "Filter",
|
short = "Filter",
|
||||||
},
|
},
|
||||||
|
legacy_action = "live_filter",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key = "F",
|
key = "F",
|
||||||
@@ -300,6 +336,7 @@ local DEFAULT_KEYMAPS = {
|
|||||||
long = "Clear live filter.",
|
long = "Clear live filter.",
|
||||||
short = "Clean Filter",
|
short = "Clean Filter",
|
||||||
},
|
},
|
||||||
|
legacy_action = "clear_live_filter",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key = "q",
|
key = "q",
|
||||||
@@ -308,6 +345,7 @@ local DEFAULT_KEYMAPS = {
|
|||||||
long = "Close tree window.",
|
long = "Close tree window.",
|
||||||
short = "Close",
|
short = "Close",
|
||||||
},
|
},
|
||||||
|
legacy_action = "close",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key = "W",
|
key = "W",
|
||||||
@@ -316,6 +354,7 @@ local DEFAULT_KEYMAPS = {
|
|||||||
long = "Collapse the whole tree.",
|
long = "Collapse the whole tree.",
|
||||||
short = "Collapse",
|
short = "Collapse",
|
||||||
},
|
},
|
||||||
|
legacy_action = "collapse_all",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key = "E",
|
key = "E",
|
||||||
@@ -324,6 +363,7 @@ local DEFAULT_KEYMAPS = {
|
|||||||
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.",
|
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.",
|
||||||
short = "Expand All",
|
short = "Expand All",
|
||||||
},
|
},
|
||||||
|
legacy_action = "expand_all",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key = "S",
|
key = "S",
|
||||||
@@ -332,6 +372,7 @@ local DEFAULT_KEYMAPS = {
|
|||||||
long = "Prompt the user to enter a path and then expands the tree to match the path.",
|
long = "Prompt the user to enter a path and then expands the tree to match the path.",
|
||||||
short = "Search",
|
short = "Search",
|
||||||
},
|
},
|
||||||
|
legacy_action = "search_node",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key = ".",
|
key = ".",
|
||||||
@@ -340,6 +381,7 @@ local DEFAULT_KEYMAPS = {
|
|||||||
long = "Enter vim command mode with the file the cursor is on.",
|
long = "Enter vim command mode with the file the cursor is on.",
|
||||||
short = "Run Command",
|
short = "Run Command",
|
||||||
},
|
},
|
||||||
|
legacy_action = "run_file_command",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key = "<C-k>",
|
key = "<C-k>",
|
||||||
@@ -348,6 +390,7 @@ local DEFAULT_KEYMAPS = {
|
|||||||
long = "Toggle a popup with file info about the file under the cursor.",
|
long = "Toggle a popup with file info about the file under the cursor.",
|
||||||
short = "Info",
|
short = "Info",
|
||||||
},
|
},
|
||||||
|
legacy_action = "toggle_file_info",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key = "g?",
|
key = "g?",
|
||||||
@@ -356,6 +399,7 @@ local DEFAULT_KEYMAPS = {
|
|||||||
long = "Toggle help.",
|
long = "Toggle help.",
|
||||||
short = "Help",
|
short = "Help",
|
||||||
},
|
},
|
||||||
|
legacy_action = "toggle_help",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key = "m",
|
key = "m",
|
||||||
@@ -364,6 +408,7 @@ local DEFAULT_KEYMAPS = {
|
|||||||
long = "Toggle node in bookmarks.",
|
long = "Toggle node in bookmarks.",
|
||||||
short = "Toggle Bookmark",
|
short = "Toggle Bookmark",
|
||||||
},
|
},
|
||||||
|
legacy_action = "toggle_mark",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key = "bmv",
|
key = "bmv",
|
||||||
@@ -372,6 +417,7 @@ local DEFAULT_KEYMAPS = {
|
|||||||
long = "Move all bookmarked nodes into specified location.",
|
long = "Move all bookmarked nodes into specified location.",
|
||||||
short = "Move Bookmarked",
|
short = "Move Bookmarked",
|
||||||
},
|
},
|
||||||
|
legacy_action = "bulk_move",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
-- END_DEFAULT_KEYMAPS
|
-- END_DEFAULT_KEYMAPS
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
local utils = require "nvim-tree.utils"
|
local utils = require "nvim-tree.utils"
|
||||||
local Api = require "nvim-tree.api"
|
|
||||||
|
local DEFAULT_KEYMAPS = require("nvim-tree.keymap").DEFAULT_KEYMAPS
|
||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
@@ -298,55 +299,6 @@ local function removed(opts)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local OLD_MAPPING_TABLE = {
|
|
||||||
edit = Api.node.open.edit,
|
|
||||||
edit_in_place = Api.node.open.replace_tree_buffer,
|
|
||||||
edit_no_picker = Api.node.open.no_window_picker,
|
|
||||||
cd = Api.tree.change_root_to_node,
|
|
||||||
vsplit = Api.node.open.vertical,
|
|
||||||
split = Api.node.open.horizontal,
|
|
||||||
tabnew = Api.node.open.tab,
|
|
||||||
preview = Api.node.open.preview,
|
|
||||||
prev_sibling = Api.node.navigate.sibling.prev,
|
|
||||||
next_sibling = Api.node.navigate.sibling.next,
|
|
||||||
parent_node = Api.node.navigate.parent,
|
|
||||||
close_node = Api.node.navigate.parent_close,
|
|
||||||
first_sibling = Api.node.navigate.sibling.first,
|
|
||||||
last_sibling = Api.node.navigate.sibling.last,
|
|
||||||
toggle_git_ignored = Api.tree.toggle_gitignore_filter,
|
|
||||||
toggle_dotfiles = Api.tree.toggle_hidden_filter,
|
|
||||||
toggle_custom = Api.tree.toggle_custom_filter,
|
|
||||||
refresh = Api.tree.reload,
|
|
||||||
create = Api.fs.create,
|
|
||||||
remove = Api.fs.remove,
|
|
||||||
trash = Api.fs.trash,
|
|
||||||
rename = Api.fs.rename,
|
|
||||||
full_rename = Api.fs.rename_sub,
|
|
||||||
cut = Api.fs.cut,
|
|
||||||
copy = Api.fs.copy.node,
|
|
||||||
paste = Api.fs.paste,
|
|
||||||
copy_name = Api.fs.copy.filename,
|
|
||||||
copy_path = Api.fs.copy.relative_path,
|
|
||||||
copy_absolute_path = Api.fs.copy.absolute_path,
|
|
||||||
prev_git_item = Api.node.navigate.git.prev,
|
|
||||||
next_git_item = Api.node.navigate.git.next,
|
|
||||||
prev_diag_item = Api.node.navigate.diagnostics.prev,
|
|
||||||
next_diag_item = Api.node.navigate.diagnostics.next,
|
|
||||||
dir_up = Api.tree.change_root_to_parent,
|
|
||||||
system_open = Api.node.run.system,
|
|
||||||
live_filter = Api.live_filter.start,
|
|
||||||
clear_live_filter = Api.live_filter.clear,
|
|
||||||
close = Api.tree.close,
|
|
||||||
collapse_all = Api.tree.collapse_all,
|
|
||||||
expand_all = Api.tree.expand_all,
|
|
||||||
search_node = Api.tree.search_node,
|
|
||||||
run_file_command = Api.node.run.cmd,
|
|
||||||
toggle_file_info = Api.node.show_info_popup,
|
|
||||||
toggle_help = Api.tree.toggle_help,
|
|
||||||
toggle_mark = Api.marks.toggle,
|
|
||||||
bulk_move = Api.marks.bulk.move,
|
|
||||||
}
|
|
||||||
|
|
||||||
function M.move_mappings_to_keymap(opts)
|
function M.move_mappings_to_keymap(opts)
|
||||||
if opts.on_attach == "disable" and opts.view and opts.view.mappings then
|
if opts.on_attach == "disable" and opts.view and opts.view.mappings then
|
||||||
local custom_only, list = opts.view.mappings.custom_only, opts.view.mappings.list
|
local custom_only, list = opts.view.mappings.custom_only, opts.view.mappings.list
|
||||||
@@ -355,24 +307,35 @@ function M.move_mappings_to_keymap(opts)
|
|||||||
opts.view.mappings.custom_only = nil
|
opts.view.mappings.custom_only = nil
|
||||||
end
|
end
|
||||||
if list then
|
if list then
|
||||||
|
local keymap_by_action = utils.key_by(DEFAULT_KEYMAPS, "legacy_action")
|
||||||
if not custom_only then
|
if not custom_only then
|
||||||
opts.remove_keymaps = {}
|
opts.remove_keymaps = {}
|
||||||
end
|
end
|
||||||
local call_list = {}
|
local call_list = {}
|
||||||
opts.on_attach = function(bufnr)
|
opts.on_attach = function(bufnr)
|
||||||
for _, el in pairs(call_list) do
|
for _, el in pairs(call_list) do
|
||||||
|
if el.callback then
|
||||||
vim.keymap.set(el.mode or "n", el.key, el.callback, { buffer = bufnr, remap = false, silent = true })
|
vim.keymap.set(el.mode or "n", el.key, el.callback, { buffer = bufnr, remap = false, silent = true })
|
||||||
|
elseif el.keymap then
|
||||||
|
vim.keymap.set(
|
||||||
|
el.mode or "n",
|
||||||
|
el.key,
|
||||||
|
el.keymap.callback,
|
||||||
|
{ buffer = bufnr, remap = false, silent = true, desc = el.keymap.desc.short }
|
||||||
|
)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
for _, map in pairs(list) do
|
for _, map in pairs(list) do
|
||||||
local keys = type(map.key) == "table" and map.key or { map.key }
|
local keys = type(map.key) == "table" and map.key or { map.key }
|
||||||
local mode = map.mode or "n"
|
local mode = map.mode or "n"
|
||||||
local callback
|
local callback
|
||||||
|
local keymap
|
||||||
if map.action ~= "" then
|
if map.action ~= "" then
|
||||||
if map.action_cb then
|
if map.action_cb then
|
||||||
callback = map.action_cb
|
callback = map.action_cb
|
||||||
else
|
elseif keymap_by_action[map.action] then
|
||||||
callback = OLD_MAPPING_TABLE[map.action]
|
keymap = keymap_by_action[map.action]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -383,6 +346,8 @@ function M.move_mappings_to_keymap(opts)
|
|||||||
|
|
||||||
if callback then
|
if callback then
|
||||||
table.insert(call_list, { mode = mode, key = k, callback = callback })
|
table.insert(call_list, { mode = mode, key = k, callback = callback })
|
||||||
|
elseif keymap then
|
||||||
|
table.insert(call_list, { mode = mode, key = k, keymap = keymap })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -342,8 +342,10 @@ end
|
|||||||
function M.key_by(tbl, key)
|
function M.key_by(tbl, key)
|
||||||
local keyed = {}
|
local keyed = {}
|
||||||
for _, val in ipairs(tbl) do
|
for _, val in ipairs(tbl) do
|
||||||
|
if val[key] then
|
||||||
keyed[val[key]] = val
|
keyed[val[key]] = val
|
||||||
end
|
end
|
||||||
|
end
|
||||||
return keyed
|
return keyed
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user