Skip to content

Commit

Permalink
fix: disable ui then bulk edit
Browse files Browse the repository at this point in the history
  • Loading branch information
phanen committed May 7, 2024
1 parent bd62fe3 commit 7a4454c
Showing 1 changed file with 36 additions and 18 deletions.
54 changes: 36 additions & 18 deletions lua/fzf-lua-overlay/actions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -80,25 +80,43 @@ M.file_create_open = function(_, opts)
vim.cmd.e(path)
end

local delete_files = function(paths)
for _, path in pairs(paths) do
if vim.uv.fs_stat(path) then
vim.uv.fs_unlink(path)
vim.notify(('%s has been deleted'):format(path), vim.log.levels.INFO)
end
end
end

M.file_delete = function(selected, opts)
-- TODO: multi?
-- local cwd = opts.cwd or vim.fn.getcwd()
-- local path = vim.fn.expand(('%s/%s'):format(cwd, selected[1]))
local file = require('fzf-lua').path.entry_to_file(selected[1], opts)
local path = file.path
local _fn, _opts = opts.__call_fn, opts.__call_opts
require('fzf-lua').fzf_exec({ 'YES', 'NO' }, {
prompt = ('Delete %s'):format(path),
actions = {
['default'] = function(sel)
if sel[1] == 'YES' and vim.uv.fs_stat(path) then
vim.uv.fs_unlink(path)
vim.notify(('%s has been deleted'):format(path), vim.log.levels.INFO)
end
_fn(_opts)
end,
},
})
-- prompt break `reload = true`
-- local _fn, _opts = opts.__call_fn, opts.__call_opts

-- may a log for undo? git reset?
local paths = vim.tbl_map(
function(v) return require('fzf-lua').path.entry_to_file(v, opts).path end,
selected
)

delete_files(paths)

-- require('fzf-lua').fzf_exec({ 'YES', 'NO' }, {
-- prompt = ('Delete %s'):format(table.concat(paths, ' ')),
-- actions = {
-- ['default'] = function(sel)
-- if sel[1] == 'YES' then delete_files(paths) end
-- -- _fn(_opts)
-- end,
-- },
-- })

-- vim.ui.select({ 'y', 'n' }, {
-- prompt = 'delete or not?',
-- -- format_item = function(item) end,
-- }, function(choice)
-- if not choice:match('n') then delete_files(paths) end
-- end)
end

-- used by fzf's builtin file pickers
Expand Down

0 comments on commit 7a4454c

Please sign in to comment.