I've been living in a rent-free apartment for years. The owner tells me he's just sold it. Can I ask for the sale to be annulled because he didn't offer it to me as a priority?

No. You're probably thinking of the tenant's right of pre-emption under a residential lease (provided for in article 15 of the law of July 6, 1989). In your case, you are not a tenant, as you occupy the property free of charge. The owner is therefore under no obligation to offer you the property for sale.you the property for sale.