Add :Remove command, to remove file of current buffer
This commit is contained in:
18
lua/commands.lua
Normal file
18
lua/commands.lua
Normal file
@@ -0,0 +1,18 @@
|
||||
-- TODO: :Rename
|
||||
-- vim.loop.fs_rename
|
||||
|
||||
-- :Remove the file associated with the current buffer, then delete the buffer
|
||||
vim.api.nvim_create_user_command('Remove', function()
|
||||
local path = vim.fn.expand('%:p')
|
||||
vim.loop.fs_unlink(path, function(err, success)
|
||||
if success then
|
||||
vim.schedule(function()
|
||||
vim.api.nvim_buf_delete(vim.api.nvim_get_current_buf(), {})
|
||||
end)
|
||||
else
|
||||
error(err)
|
||||
end
|
||||
end)
|
||||
end, {})
|
||||
|
||||
-- TODO: :Move
|
||||
Reference in New Issue
Block a user