nvim/lua/commands.lua

19 lines
454 B
Lua

-- 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