fix(#2024): revert removal of deprecated nvim-tree.config nvim_tree_callback
This commit is contained in:
11
lua/nvim-tree/config.lua
Normal file
11
lua/nvim-tree/config.lua
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
-- INFO: DEPRECATED FILE, DO NOT ADD ANYTHING IN THERE
|
||||||
|
-- keeping to avoid breaking user configs. Will remove during a weekend.
|
||||||
|
local M = {}
|
||||||
|
|
||||||
|
-- TODO: remove this once the cb property is not supported in mappings, following view.mapping.list removal
|
||||||
|
function M.nvim_tree_callback(callback_name)
|
||||||
|
-- generate_on_attach_.* will map this as per mappings.list..action
|
||||||
|
return callback_name
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
@@ -241,19 +241,26 @@ local function generate_on_attach_function(list, unmapped_keys, remove_defaults)
|
|||||||
for _, m in ipairs(M.on_attach.list) do
|
for _, m in ipairs(M.on_attach.list) 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 _, k in ipairs(keys) do
|
for _, k in ipairs(keys) do
|
||||||
if LEGACY_MAPPINGS[m.action] then
|
local legacy_mapping = LEGACY_MAPPINGS[m.action] or LEGACY_MAPPINGS[m.cb]
|
||||||
-- straight action
|
if legacy_mapping then
|
||||||
|
-- straight action or cb, which generated an action string at setup time
|
||||||
vim.keymap.set(
|
vim.keymap.set(
|
||||||
m.mode or "n",
|
m.mode or "n",
|
||||||
k,
|
k,
|
||||||
LEGACY_MAPPINGS[m.action].fn,
|
legacy_mapping.fn,
|
||||||
{ desc = m.action, buffer = bufnr, noremap = true, silent = true, nowait = true }
|
{ desc = m.cb or m.action, buffer = bufnr, noremap = true, silent = true, nowait = true }
|
||||||
)
|
)
|
||||||
elseif type(m.action_cb) == "function" then
|
elseif type(m.action_cb) == "function" then
|
||||||
-- action_cb
|
-- action_cb
|
||||||
vim.keymap.set(m.mode or "n", k, function()
|
vim.keymap.set(m.mode or "n", k, function()
|
||||||
m.action_cb(api.tree.get_node_under_cursor())
|
m.action_cb(api.tree.get_node_under_cursor())
|
||||||
end, { desc = m.action, buffer = bufnr, noremap = true, silent = true, nowait = true })
|
end, {
|
||||||
|
desc = m.action or "no description",
|
||||||
|
buffer = bufnr,
|
||||||
|
noremap = true,
|
||||||
|
silent = true,
|
||||||
|
nowait = true,
|
||||||
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -285,21 +292,22 @@ local function generate_on_attach_lua(list, unmapped_keys, remove_defaults)
|
|||||||
for _, m in ipairs(list) do
|
for _, m in ipairs(list) 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 _, k in ipairs(keys) do
|
for _, k in ipairs(keys) do
|
||||||
if LEGACY_MAPPINGS[m.action] then
|
local legacy_mapping = LEGACY_MAPPINGS[m.action] or LEGACY_MAPPINGS[m.cb]
|
||||||
|
if legacy_mapping then
|
||||||
lua = lua
|
lua = lua
|
||||||
.. string.format(
|
.. string.format(
|
||||||
[[ vim.keymap.set('%s', '%s', %s, opts('%s'))]],
|
[[ vim.keymap.set('%s', '%s', %s, opts('%s'))]],
|
||||||
m.mode or "n",
|
m.mode or "n",
|
||||||
k,
|
k,
|
||||||
LEGACY_MAPPINGS[m.action].n,
|
legacy_mapping.n,
|
||||||
LEGACY_MAPPINGS[m.action].desc
|
legacy_mapping.desc
|
||||||
)
|
)
|
||||||
.. "\n"
|
.. "\n"
|
||||||
elseif type(m.action_cb) == "function" then
|
elseif type(m.action_cb) == "function" then
|
||||||
lua = lua .. string.format([[ vim.keymap.set('%s', '%s', function()]], m.mode or "n", k) .. "\n"
|
lua = lua .. string.format([[ vim.keymap.set('%s', '%s', function()]], m.mode or "n", k) .. "\n"
|
||||||
lua = lua .. [[ local node = api.tree.get_node_under_cursor()]] .. "\n"
|
lua = lua .. [[ local node = api.tree.get_node_under_cursor()]] .. "\n"
|
||||||
lua = lua .. [[ -- your code goes here]] .. "\n"
|
lua = lua .. [[ -- your code goes here]] .. "\n"
|
||||||
lua = lua .. string.format([[ end, opts('%s'))]], m.action) .. "\n\n"
|
lua = lua .. string.format([[ end, opts('%s'))]], m.action or "no description") .. "\n\n"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user