Skip to content

Commit 0882354

Browse files
feat(#2148): api.fs.rename_full (#2461)
* feat(#2148): add rename_full in API * feat(#2148): add default mapping 'u' for rename_full --------- Co-authored-by: Alexander Courtis <alex@courtis.org>
1 parent 57078f9 commit 0882354

File tree

4 files changed

+11
-0
lines changed

4 files changed

+11
-0
lines changed

doc/nvim-tree-lua.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ Show the mappings: `g?`
188188
`s` Run System |nvim-tree-api.node.run.system()|
189189
`S` Search |nvim-tree-api.tree.search_node()|
190190
`U` Toggle Filter: Hidden |nvim-tree-api.tree.toggle_custom_filter()|
191+
`u` Rename: Full Path |nvim-tree-api.fs.rename_full()|
191192
`W` Collapse |nvim-tree-api.tree.collapse_all()|
192193
`x` Cut |nvim-tree-api.fs.cut()|
193194
`y` Copy Name |nvim-tree-api.fs.copy.filename()|
@@ -1717,6 +1718,12 @@ fs.rename_sub({node}) *nvim-tree-api.fs.rename_sub()*
17171718
Parameters: ~
17181719
{node} (Node) file or folder
17191720

1721+
fs.rename_full({node}) *nvim-tree-api.fs.rename_full()*
1722+
Prompt to rename a file or folder by absolute path.
1723+
1724+
Parameters: ~
1725+
{node} (Node) file or folder
1726+
17201727
fs.cut({node}) *nvim-tree-api.fs.cut()*
17211728
Cut a file or folder to the nvim-tree clipboard.
17221729

@@ -2106,6 +2113,7 @@ You are encouraged to copy these to your own |nvim-tree.on_attach| function.
21062113
vim.keymap.set('n', 's', api.node.run.system, opts('Run System'))
21072114
vim.keymap.set('n', 'S', api.tree.search_node, opts('Search'))
21082115
vim.keymap.set('n', 'U', api.tree.toggle_custom_filter, opts('Toggle Filter: Hidden'))
2116+
vim.keymap.set('n', 'u', api.fs.rename_full, opts('Rename: Full Path'))
21092117
vim.keymap.set('n', 'W', api.tree.collapse_all, opts('Collapse'))
21102118
vim.keymap.set('n', 'x', api.fs.cut, opts('Cut'))
21112119
vim.keymap.set('n', 'y', api.fs.copy.filename, opts('Copy Name'))

lua/nvim-tree/actions/fs/rename-file.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ local M = {
1010
}
1111

1212
local ALLOWED_MODIFIERS = {
13+
[":p"] = true,
1314
[":p:h"] = true,
1415
[":t"] = true,
1516
[":t:r"] = true,

lua/nvim-tree/api.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ Api.fs.rename_node = wrap_node(require("nvim-tree.actions.fs.rename-file").fn ":
141141
Api.fs.rename = wrap_node(require("nvim-tree.actions.fs.rename-file").fn ":t")
142142
Api.fs.rename_sub = wrap_node(require("nvim-tree.actions.fs.rename-file").fn ":p:h")
143143
Api.fs.rename_basename = wrap_node(require("nvim-tree.actions.fs.rename-file").fn ":t:r")
144+
Api.fs.rename_full = wrap_node(require("nvim-tree.actions.fs.rename-file").fn ":p")
144145
Api.fs.cut = wrap_node(require("nvim-tree.actions.fs.copy-paste").cut)
145146
Api.fs.paste = wrap_node(require("nvim-tree.actions.fs.copy-paste").paste)
146147
Api.fs.clear_clipboard = wrap(require("nvim-tree.actions.fs.copy-paste").clear_clipboard)

lua/nvim-tree/keymap.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ function M.default_on_attach(bufnr)
8282
vim.keymap.set('n', 's', api.node.run.system, opts('Run System'))
8383
vim.keymap.set('n', 'S', api.tree.search_node, opts('Search'))
8484
vim.keymap.set('n', 'U', api.tree.toggle_custom_filter, opts('Toggle Filter: Hidden'))
85+
vim.keymap.set('n', 'u', api.fs.rename_full, opts('Rename: Full Path'))
8586
vim.keymap.set('n', 'W', api.tree.collapse_all, opts('Collapse'))
8687
vim.keymap.set('n', 'x', api.fs.cut, opts('Cut'))
8788
vim.keymap.set('n', 'y', api.fs.copy.filename, opts('Copy Name'))

0 commit comments

Comments
 (0)