If you have a US primary residence and a EU secondary residence,is it possible to switch primary residency to the EU home in order to avoid capital gain tax if selling?

I spend 5 months a year in my EU home.  I have owned it for 20+ years, and have never rented it.  If I'm looking to sell in 5 years, I would like to avoid paying any US taxes on the sale.  I would appreciate any advice.