I had a client who was thinking about doing the same thing, but after sitting down with her, we were able to get her on track and move foward to purchase a home without filing bankruptcy.
FHA may allow only 2 years from discharge and that would be determined by the circumstances leading up to your BK.
If you are contemplating BK, you have bigger issues than worrying about buying a home. Nothing wrong with renting.
There are some companies that will help you clean up your credit report after the BK, you can PM me if you want a name. But, of course, I cannot guarantee anyone else's work, but they've worked for a couple of my clients, so they could buy earlier rather than later.