You may want to send a "response" to the lawsuit so it's on record that you are leasing. That way you should be able to stay until your lease expires--that is as long as your are paying a fair market rental price. An attorney can file a response for you. Some people also file their own response.. I'm not an attorney and have to tell you to seek legal advice.
Also don't think you can stop paying your rent because the landlord's foreclosure has nothing to do with your rental agreement. The landlord can file an eviction against you and it could injure your chances of getting your next rental or better yet your first home!
Hope this helps.