chore(mappings): add desc to all mappings
This commit is contained in:
@@ -185,15 +185,15 @@ local DEFAULT_KEYMAPS = {
|
|||||||
key = "<C-r>",
|
key = "<C-r>",
|
||||||
callback = Api.fs.rename_sub,
|
callback = Api.fs.rename_sub,
|
||||||
desc = {
|
desc = {
|
||||||
long = "rename a file 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",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key = "x",
|
key = "x",
|
||||||
callback = Api.fs.cut,
|
callback = Api.fs.cut,
|
||||||
desc = {
|
desc = {
|
||||||
long = "add/remove file/directory to cut clipboard",
|
long = "Cut file or directory to cut clipboard.",
|
||||||
short = "Cut",
|
short = "Cut",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -201,7 +201,7 @@ local DEFAULT_KEYMAPS = {
|
|||||||
key = "c",
|
key = "c",
|
||||||
callback = Api.fs.copy.node,
|
callback = Api.fs.copy.node,
|
||||||
desc = {
|
desc = {
|
||||||
long = "add/remove file/directory to copy clipboard",
|
long = "Copy file or directory to copy clipboard.",
|
||||||
short = "Copy",
|
short = "Copy",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -209,7 +209,7 @@ local DEFAULT_KEYMAPS = {
|
|||||||
key = "p",
|
key = "p",
|
||||||
callback = Api.fs.paste,
|
callback = Api.fs.paste,
|
||||||
desc = {
|
desc = {
|
||||||
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",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -217,15 +217,15 @@ local DEFAULT_KEYMAPS = {
|
|||||||
key = "y",
|
key = "y",
|
||||||
callback = Api.fs.copy.filename,
|
callback = Api.fs.copy.filename,
|
||||||
desc = {
|
desc = {
|
||||||
long = "copy name to system clipboard",
|
long = "Copy name to system clipboard.",
|
||||||
short = "Copy File Name",
|
short = "Copy Name",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key = "Y",
|
key = "Y",
|
||||||
callback = Api.fs.copy.relative_path,
|
callback = Api.fs.copy.relative_path,
|
||||||
desc = {
|
desc = {
|
||||||
long = "copy relative path to system clipboard",
|
long = "Copy relative path to system clipboard.",
|
||||||
short = "Copy Relative Path",
|
short = "Copy Relative Path",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -233,7 +233,7 @@ local DEFAULT_KEYMAPS = {
|
|||||||
key = "gy",
|
key = "gy",
|
||||||
callback = Api.fs.copy.absolute_path,
|
callback = Api.fs.copy.absolute_path,
|
||||||
desc = {
|
desc = {
|
||||||
long = "copy absolute path to system clipboard",
|
long = "Copy absolute path to system clipboard.",
|
||||||
short = "Copy Absolute Path",
|
short = "Copy Absolute Path",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -241,7 +241,7 @@ local DEFAULT_KEYMAPS = {
|
|||||||
key = "[e",
|
key = "[e",
|
||||||
callback = Api.node.navigate.diagnostics.next,
|
callback = Api.node.navigate.diagnostics.next,
|
||||||
desc = {
|
desc = {
|
||||||
long = "go to next diagnostic item",
|
long = "Go to next diagnostic item.",
|
||||||
short = "Next Diagnostic",
|
short = "Next Diagnostic",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -249,7 +249,7 @@ local DEFAULT_KEYMAPS = {
|
|||||||
key = "[c",
|
key = "[c",
|
||||||
callback = Api.node.navigate.git.next,
|
callback = Api.node.navigate.git.next,
|
||||||
desc = {
|
desc = {
|
||||||
long = "go to next git item",
|
long = "Go to next git item.",
|
||||||
short = "Next Git",
|
short = "Next Git",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -257,7 +257,7 @@ local DEFAULT_KEYMAPS = {
|
|||||||
key = "]e",
|
key = "]e",
|
||||||
callback = Api.node.navigate.diagnostics.prev,
|
callback = Api.node.navigate.diagnostics.prev,
|
||||||
desc = {
|
desc = {
|
||||||
long = "go to prev diagnostic item",
|
long = "Go to prev diagnostic item.",
|
||||||
short = "Prev Diagnostic",
|
short = "Prev Diagnostic",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -265,7 +265,7 @@ local DEFAULT_KEYMAPS = {
|
|||||||
key = "]c",
|
key = "]c",
|
||||||
callback = Api.node.navigate.git.prev,
|
callback = Api.node.navigate.git.prev,
|
||||||
desc = {
|
desc = {
|
||||||
long = "go to prev git item",
|
long = "Go to prev git item.",
|
||||||
short = "Prev Git",
|
short = "Prev Git",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -273,7 +273,7 @@ local DEFAULT_KEYMAPS = {
|
|||||||
key = "-",
|
key = "-",
|
||||||
callback = Api.tree.change_root_to_parent,
|
callback = Api.tree.change_root_to_parent,
|
||||||
desc = {
|
desc = {
|
||||||
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",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -369,7 +369,7 @@ local DEFAULT_KEYMAPS = {
|
|||||||
key = "bmv",
|
key = "bmv",
|
||||||
callback = Api.marks.bulk.move,
|
callback = Api.marks.bulk.move,
|
||||||
desc = {
|
desc = {
|
||||||
long = "Move all bookmarked nodes into specified location",
|
long = "Move all bookmarked nodes into specified location.",
|
||||||
short = "Move Bookmarked",
|
short = "Move Bookmarked",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -70,20 +70,20 @@ function M.compute_lines()
|
|||||||
|
|
||||||
local buf_keymaps = vim.api.nvim_buf_get_keymap(vim.api.nvim_get_current_buf(), "")
|
local buf_keymaps = vim.api.nvim_buf_get_keymap(vim.api.nvim_get_current_buf(), "")
|
||||||
|
|
||||||
local processed = vim.tbl_map(function(bkm)
|
local lines = vim.tbl_map(function(bkm)
|
||||||
return { lhs = tidy_lhs(bkm.lhs), desc = bkm.desc }
|
return { lhs = tidy_lhs(bkm.lhs), desc = bkm.desc }
|
||||||
end, buf_keymaps)
|
end, buf_keymaps)
|
||||||
|
|
||||||
table.sort(processed, function(a, b)
|
table.sort(lines, function(a, b)
|
||||||
return sort_lhs(a.lhs, b.lhs)
|
return sort_lhs(a.lhs, b.lhs)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
for _, p in pairs(processed) do
|
for _, p in pairs(lines) do
|
||||||
p.lhs = shorten_lhs(p.lhs)
|
p.lhs = shorten_lhs(p.lhs)
|
||||||
end
|
end
|
||||||
|
|
||||||
local num = 0
|
local num = 0
|
||||||
for _, p in pairs(processed) do
|
for _, p in pairs(lines) do
|
||||||
num = num + 1
|
num = num + 1
|
||||||
local bind_string = string.format("%-6.6s %s", shorten_lhs(p.lhs), p.desc)
|
local bind_string = string.format("%-6.6s %s", shorten_lhs(p.lhs), p.desc)
|
||||||
table.insert(help_lines, bind_string)
|
table.insert(help_lines, bind_string)
|
||||||
|
|||||||
@@ -3,8 +3,9 @@
|
|||||||
|
|
||||||
-- write DEFAULT_KEYMAPS in various formats
|
-- write DEFAULT_KEYMAPS in various formats
|
||||||
|
|
||||||
local max_key_help = 0
|
local max_key = 0
|
||||||
local max_short_help = 0
|
local max_short = 0
|
||||||
|
local max_callback = 0
|
||||||
local outs_help = {}
|
local outs_help = {}
|
||||||
|
|
||||||
for _, m in pairs(DEFAULT_KEYMAPS) do
|
for _, m in pairs(DEFAULT_KEYMAPS) do
|
||||||
@@ -13,22 +14,23 @@ for _, m in pairs(DEFAULT_KEYMAPS) do
|
|||||||
for _, key in ipairs(keys) do
|
for _, key in ipairs(keys) do
|
||||||
local out = {}
|
local out = {}
|
||||||
out.key = key
|
out.key = key
|
||||||
max_key_help = math.max(#out.key, max_key_help)
|
max_key = math.max(#out.key, max_key)
|
||||||
if first then
|
if first then
|
||||||
out.short = m.desc.short
|
out.short = m.desc.short
|
||||||
max_short_help = math.max(#out.short, max_short_help)
|
max_short = math.max(#out.short, max_short)
|
||||||
out.long = m.desc.long
|
out.long = m.desc.long
|
||||||
first = false
|
first = false
|
||||||
end
|
end
|
||||||
table.insert(outs_help, out)
|
table.insert(outs_help, out)
|
||||||
end
|
end
|
||||||
|
max_callback = math.max(#m.callback, max_callback)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- help
|
-- help
|
||||||
local file = io.open("/tmp/DEFAULT_KEYMAPS.help", "w")
|
local file = io.open("/tmp/DEFAULT_KEYMAPS.help", "w")
|
||||||
io.output(file)
|
io.output(file)
|
||||||
io.write "\n"
|
io.write "\n"
|
||||||
local fmt = string.format("%%-%d.%ds %%-%d.%ds %%s\n", max_key_help, max_key_help, max_short_help, max_short_help)
|
local fmt = string.format("%%-%d.%ds %%-%d.%ds %%s\n", max_key, max_key, max_short, max_short)
|
||||||
for _, m in pairs(outs_help) do
|
for _, m in pairs(outs_help) do
|
||||||
if not m.short then
|
if not m.short then
|
||||||
io.write(string.format("%s\n", m.key))
|
io.write(string.format("%s\n", m.key))
|
||||||
@@ -42,12 +44,19 @@ io.close(file)
|
|||||||
-- lua on_attach
|
-- lua on_attach
|
||||||
file = io.open("/tmp/DEFAULT_KEYMAPS.on_attach.lua", "w")
|
file = io.open("/tmp/DEFAULT_KEYMAPS.on_attach.lua", "w")
|
||||||
io.output(file)
|
io.output(file)
|
||||||
io.write "local function on_attach(bufnr, mode, opts)\n"
|
io.write "local Api = require('nvim-tree.api')\n\n"
|
||||||
io.write "local Api = require('nvim-tree.api')\n"
|
io.write "local function on_attach(bufnr)\n"
|
||||||
|
fmt = string.format(
|
||||||
|
" vim.keymap.set('n', %%-%d.%ds %%-%d.%ds { buffer = bufnr, noremap = true, silent = true, nowait = true, desc = '%%s', })\n",
|
||||||
|
max_key + 3,
|
||||||
|
max_key + 3,
|
||||||
|
max_callback + 1,
|
||||||
|
max_callback + 1
|
||||||
|
)
|
||||||
for _, m in pairs(DEFAULT_KEYMAPS) do
|
for _, m in pairs(DEFAULT_KEYMAPS) do
|
||||||
local keys = type(m.key) == "table" and m.key or { m.key }
|
local keys = type(m.key) == "table" and m.key or { m.key }
|
||||||
for _, key in ipairs(keys) do
|
for _, key in ipairs(keys) do
|
||||||
io.write(string.format(" vim.keymap.set(mode, '%s', %s, opts)\n", key, m.callback))
|
io.write(string.format(fmt, "'" .. key .. "',", m.callback .. ",", m.desc.short))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
io.write "end\n"
|
io.write "end\n"
|
||||||
|
|||||||
Reference in New Issue
Block a user