mirror of
https://github.com/folke/snacks.nvim
synced 2025-08-05 19:28:24 +00:00
feat(rename): add old
to on_rename
callback
This commit is contained in:
parent
969608ab79
commit
455228ed3a
2 changed files with 5 additions and 2 deletions
|
@ -148,6 +148,9 @@ function M.files(opts, ctx)
|
||||||
if not cmd then
|
if not cmd then
|
||||||
return function() end
|
return function() end
|
||||||
end
|
end
|
||||||
|
if opts.debug.files then
|
||||||
|
Snacks.notify(cmd .. " " .. table.concat(args or {}, " "))
|
||||||
|
end
|
||||||
return require("snacks.picker.source.proc").proc({
|
return require("snacks.picker.source.proc").proc({
|
||||||
opts,
|
opts,
|
||||||
{
|
{
|
||||||
|
|
|
@ -14,7 +14,7 @@ end
|
||||||
|
|
||||||
-- Prompt for the new filename,
|
-- Prompt for the new filename,
|
||||||
-- do the rename, and trigger LSP handlers
|
-- 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)
|
function M.rename_file(opts)
|
||||||
opts = opts or {}
|
opts = opts or {}
|
||||||
local buf = vim.api.nvim_get_current_buf()
|
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.api.nvim_buf_delete(buf, { force = true })
|
||||||
vim.fn.delete(old)
|
vim.fn.delete(old)
|
||||||
if opts.on_rename then
|
if opts.on_rename then
|
||||||
opts.on_rename(new)
|
opts.on_rename(new, old)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue