Helping a friend who's learning French with their homeworks, they've asked me about the usage of the word "lui", making me realize how unpredictable its usage is to someone learning the language.
Je lui ai donné le livre. | I gave the book to him/her.
J’habitais avec lui. | I was living with him.
@neauoire shit, pas évident. J'ai trouvé ça
https://forum.wordreference.com/threads/fr-me-te-lui-etc-%C3%A0-moi-%C3%A0-toi-%C3%A0-lui-%C3%A0-elle-etc-pronom-indirect-%C3%A0-pronom-disjoint.593729/#post-3320469