I'm thinking of ignoring/staying away from a classmate even though everyone else hates him? And not buying a gift when he's expecting one.
Why do you think others hate him?
He's a bit weird.
It would be rude to ignore your classmate especially since he has so few people who want to interact with him. You should buy him the gift, it's the nice thing to do.
I still want to stay away from him and not buy him the gift.
Sometimes what you want to do is not the right thing to do. Best to do the right thing here.