aboutsummaryrefslogtreecommitdiff
path: root/lua
diff options
context:
space:
mode:
authorsrdusr <trevorgray@srdusr.com>2023-09-04 23:03:25 +0200
committersrdusr <trevorgray@srdusr.com>2023-09-04 23:03:25 +0200
commit0e2e166fca112354fa30fec33089149f435ac434 (patch)
tree274d285f3b61648bc6ca6a4acbba7454edc98add /lua
parent099801fc1dcda0fbeb4d5526d22df53bcf9ac309 (diff)
downloaddotfiles-0e2e166fca112354fa30fec33089149f435ac434.tar.gz
dotfiles-0e2e166fca112354fa30fec33089149f435ac434.zip
Function copy_file_to(node)
Diffstat (limited to 'lua')
-rw-r--r--lua/plugins/nvim-tree.lua12
1 files changed, 12 insertions, 0 deletions
diff --git a/lua/plugins/nvim-tree.lua b/lua/plugins/nvim-tree.lua
index 7571696..cc0b104 100644
--- a/lua/plugins/nvim-tree.lua
+++ b/lua/plugins/nvim-tree.lua
@@ -294,6 +294,18 @@ local function change_root_to_global_cwd()
local global_cwd = vim.fn.getcwd(-1, -1)
api.tree.change_root(global_cwd)
end
+
+local function copy_file_to(node)
+ local file_src = node['absolute_path']
+ -- The args of input are {prompt}, {default}, {completion}
+ -- Read in the new file path using the existing file's path as the baseline.
+ local file_out = vim.fn.input('COPY TO: ', file_src, 'file')
+ -- Create any parent dirs as required
+ local dir = vim.fn.fnamemodify(file_out, ':h')
+ vim.fn.system({ 'mkdir', '-p', dir })
+ -- Copy the file
+ vim.fn.system({ 'cp', '-R', file_src, file_out })
+end
-- Highlight Groups
vim.api.nvim_command('highlight NvimTreeNormal guibg=none')