Replies: 2 comments
-
|
Beta Was this translation helpful? Give feedback.
0 replies
-
opts = {
picker = {
sources = {
explorer = {
actions = {
explorer_paste = function(picker, item) --[[Override]]
local Tree = require 'snacks.explorer.tree'
local files = vim.split(vim.fn.getreg(vim.v.register or '+') or '', '\n', { plain = true })
files = vim.tbl_filter(function(file)
-- NOTE: Use `vim.uv.fs_stat` instead of `vim.fn.filereadable`
return file ~= '' and vim.uv.fs_stat(file) ~= nil
end, files)
if #files == 0 then
return Snacks.notify.warn(('The `%s` register does not contain any files'):format(vim.v.register or '+'))
end
local dir = picker:dir()
-- NOTE: Prefer parent when directory is closed
if item.dir and not item.open then
dir = vim.fs.dirname(dir)
end
-- NOTE: Replace `Snacks.picker.util.copy`
for _, file in ipairs(files) do
-- BUG: Prevent pasting inside itself
if file == dir then
Snacks.notify.warn(string.format('Skip recursive copy: %s', file))
else
local dst = vim.fs.joinpath(dir, vim.fn.fnamemodify(file, ':t'))
local dst_unique = dst
local count = 0
while vim.uv.fs_stat(dst_unique) do
count = count + 1
dst_unique = string.format('%s (copy %d)', dst, count)
end
Snacks.picker.util.copy_path(file, dst_unique)
end
end
Tree:refresh(dir)
Tree:open(dir)
picker:update { target = dir }
end, |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi all.
I'm trying to yank a directory and paste it somewhere, but snacks gives me
The + register does not contain any files
.My steps are:
y
on a directory or multiple directories bytab
p
The + register does not contain any files
Yanking files works fine.
Is it snacks.explorer do not support yank directories or I'm doing something wrong?
Beta Was this translation helpful? Give feedback.
All reactions