Planning and Editing What You Retrieve for Enhanced Tool Learning