Add :Move command to move files around
This commit is contained in:
parent
4b4a1dbf38
commit
04b5e6e4fb
@ -50,7 +50,26 @@ vim.api.nvim_create_user_command('Remove', function(opts)
|
|||||||
vim.loop.fs_unlink(path, callback)
|
vim.loop.fs_unlink(path, callback)
|
||||||
end, { bang = true })
|
end, { bang = true })
|
||||||
|
|
||||||
-- TODO: :Move
|
-- :Move the file associated with the current buffer
|
||||||
|
vim.api.nvim_create_user_command('Move', function(opts)
|
||||||
|
local source = vim.fn.expand('%:p')
|
||||||
|
local dest = opts.args
|
||||||
|
if vim.fn.isdirectory(dest) ~= 0 then
|
||||||
|
dest = vim.fn.resolve(dest .. '/' .. vim.fn.expand('%:t'))
|
||||||
|
end
|
||||||
|
vim.loop.fs_rename(source, dest, function(err, success)
|
||||||
|
if success then
|
||||||
|
vim.schedule(function()
|
||||||
|
vim.cmd.edit(dest)
|
||||||
|
end)
|
||||||
|
else
|
||||||
|
error(err)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end, {
|
||||||
|
nargs = 1,
|
||||||
|
complete = 'file',
|
||||||
|
})
|
||||||
|
|
||||||
-- :Rename the file associated with current buffer
|
-- :Rename the file associated with current buffer
|
||||||
vim.api.nvim_create_user_command('Rename', function(opts)
|
vim.api.nvim_create_user_command('Rename', function(opts)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user