In casual dating contexts, it can be used as a "soft" version of a formal dinner invitation.

Be careful not to confuse "buying lunch" with these similar-sounding idioms:

Commonly used when someone wants to gain expert advice without paying a formal consulting fee.

A manager might offer this to get to know your career goals or provide informal mentoring.