feat(rename): add old to on_rename callback

This commit is contained in:
Folke Lemaitre 2025-02-04 17:10:55 +01:00
parent 969608ab79
commit 455228ed3a
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
2 changed files with 5 additions and 2 deletions

View file

@ -148,6 +148,9 @@ function M.files(opts, ctx)
if not cmd then
return function() end
end
if opts.debug.files then
Snacks.notify(cmd .. " " .. table.concat(args or {}, " "))
end
return require("snacks.picker.source.proc").proc({
opts,
{

View file

@ -14,7 +14,7 @@ end
-- Prompt for the new filename,
-- do the rename, and trigger LSP handlers
---@param opts? {file?: string, on_rename?: fun(file:string)}
---@param opts? {file?: string, on_rename?: fun(new:string, old:string)}
function M.rename_file(opts)
opts = opts or {}
local buf = vim.api.nvim_get_current_buf()
@ -48,7 +48,7 @@ function M.rename_file(opts)
vim.api.nvim_buf_delete(buf, { force = true })
vim.fn.delete(old)
if opts.on_rename then
opts.on_rename(new)
opts.on_rename(new, old)
end
end)
end)