From de539efc5c3ef47df29acb7b6dc85983c37f36fe Mon Sep 17 00:00:00 2001 From: Benoit Charles <19323162+b-charles@users.noreply.github.com> Date: Mon, 9 Oct 2023 16:49:48 +0200 Subject: [PATCH 1/2] feat(#2148): add rename_full in API --- doc/nvim-tree-lua.txt | 6 ++++++ lua/nvim-tree/actions/fs/rename-file.lua | 1 + lua/nvim-tree/api.lua | 1 + 3 files changed, 8 insertions(+) diff --git a/doc/nvim-tree-lua.txt b/doc/nvim-tree-lua.txt index 9f1721e6935..deb7d306a45 100644 --- a/doc/nvim-tree-lua.txt +++ b/doc/nvim-tree-lua.txt @@ -1717,6 +1717,12 @@ fs.rename_sub({node}) *nvim-tree-api.fs.rename_sub()* Parameters: ~ • {node} (Node) file or folder +fs.rename_full({node}) *nvim-tree-api.fs.rename_full()* + Prompt to rename a file or folder by absolute path. + + Parameters: ~ + • {node} (Node) file or folder + fs.cut({node}) *nvim-tree-api.fs.cut()* Cut a file or folder to the nvim-tree clipboard. diff --git a/lua/nvim-tree/actions/fs/rename-file.lua b/lua/nvim-tree/actions/fs/rename-file.lua index a21eb6c80b2..09147bf18df 100644 --- a/lua/nvim-tree/actions/fs/rename-file.lua +++ b/lua/nvim-tree/actions/fs/rename-file.lua @@ -10,6 +10,7 @@ local M = { } local ALLOWED_MODIFIERS = { + [":p"] = true, [":p:h"] = true, [":t"] = true, [":t:r"] = true, diff --git a/lua/nvim-tree/api.lua b/lua/nvim-tree/api.lua index 8b11fe5cfcb..bdb65668cef 100644 --- a/lua/nvim-tree/api.lua +++ b/lua/nvim-tree/api.lua @@ -125,6 +125,7 @@ Api.fs.rename_node = wrap_node(require("nvim-tree.actions.fs.rename-file").fn ": Api.fs.rename = wrap_node(require("nvim-tree.actions.fs.rename-file").fn ":t") Api.fs.rename_sub = wrap_node(require("nvim-tree.actions.fs.rename-file").fn ":p:h") Api.fs.rename_basename = wrap_node(require("nvim-tree.actions.fs.rename-file").fn ":t:r") +Api.fs.rename_full = wrap_node(require("nvim-tree.actions.fs.rename-file").fn ":p") Api.fs.cut = wrap_node(require("nvim-tree.actions.fs.copy-paste").cut) Api.fs.paste = wrap_node(require("nvim-tree.actions.fs.copy-paste").paste) Api.fs.clear_clipboard = wrap(require("nvim-tree.actions.fs.copy-paste").clear_clipboard) From 2f3c4f8cf403cf123df94bb15cde18d4648ee82a Mon Sep 17 00:00:00 2001 From: Alexander Courtis Date: Sun, 15 Oct 2023 13:37:36 +1100 Subject: [PATCH 2/2] feat(#2148): add default mapping 'u' for rename_full --- doc/nvim-tree-lua.txt | 4 +++- lua/nvim-tree/keymap.lua | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/doc/nvim-tree-lua.txt b/doc/nvim-tree-lua.txt index deb7d306a45..3c5c6c41b7b 100644 --- a/doc/nvim-tree-lua.txt +++ b/doc/nvim-tree-lua.txt @@ -188,6 +188,7 @@ Show the mappings: `g?` `s` Run System |nvim-tree-api.node.run.system()| `S` Search |nvim-tree-api.tree.search_node()| `U` Toggle Filter: Hidden |nvim-tree-api.tree.toggle_custom_filter()| +`u` Rename: Full Path |nvim-tree-api.fs.rename_full()| `W` Collapse |nvim-tree-api.tree.collapse_all()| `x` Cut |nvim-tree-api.fs.cut()| `y` Copy Name |nvim-tree-api.fs.copy.filename()| @@ -1717,7 +1718,7 @@ fs.rename_sub({node}) *nvim-tree-api.fs.rename_sub()* Parameters: ~ • {node} (Node) file or folder -fs.rename_full({node}) *nvim-tree-api.fs.rename_full()* +fs.rename_full({node}) *nvim-tree-api.fs.rename_full()* Prompt to rename a file or folder by absolute path. Parameters: ~ @@ -2112,6 +2113,7 @@ You are encouraged to copy these to your own |nvim-tree.on_attach| function. vim.keymap.set('n', 's', api.node.run.system, opts('Run System')) vim.keymap.set('n', 'S', api.tree.search_node, opts('Search')) vim.keymap.set('n', 'U', api.tree.toggle_custom_filter, opts('Toggle Filter: Hidden')) + vim.keymap.set('n', 'u', api.fs.rename_full, opts('Rename: Full Path')) vim.keymap.set('n', 'W', api.tree.collapse_all, opts('Collapse')) vim.keymap.set('n', 'x', api.fs.cut, opts('Cut')) vim.keymap.set('n', 'y', api.fs.copy.filename, opts('Copy Name')) diff --git a/lua/nvim-tree/keymap.lua b/lua/nvim-tree/keymap.lua index b61f3ac1ed5..7f2b80d2de8 100644 --- a/lua/nvim-tree/keymap.lua +++ b/lua/nvim-tree/keymap.lua @@ -82,6 +82,7 @@ function M.default_on_attach(bufnr) vim.keymap.set('n', 's', api.node.run.system, opts('Run System')) vim.keymap.set('n', 'S', api.tree.search_node, opts('Search')) vim.keymap.set('n', 'U', api.tree.toggle_custom_filter, opts('Toggle Filter: Hidden')) + vim.keymap.set('n', 'u', api.fs.rename_full, opts('Rename: Full Path')) vim.keymap.set('n', 'W', api.tree.collapse_all, opts('Collapse')) vim.keymap.set('n', 'x', api.fs.cut, opts('Cut')) vim.keymap.set('n', 'y', api.fs.copy.filename, opts('Copy Name'))