Lifelink causes a creature's controller to gain life equal to the damage the creature deals, regardless of what is being damaged. This is stated in CR 702.15a: 'Lifelink is a static ability that modifies the rules for damage. Damage dealt by a source with lifelink causes that source's controller to gain that much life (in addition to any other results that damage causes).'
When a creature attacks a planeswalker, combat damage is assigned and dealt to the planeswalker directly (CR 510.1c). Since the damage is still being 'dealt' by that creature, lifelink triggers off of it normally. The fact that the target is a planeswalker rather than a player or another creature makes no difference to lifelink's application.
It is worth noting that lifelink is not a triggered ability — it is a static ability that modifies damage. This means the life gain happens at the same time the damage is dealt, not afterward (CR 702.15b is implicit in the timing rules for damage).
Example: You attack your opponent's Chandra, Torch of Defiance with a 3/3 creature that has lifelink. Your opponent blocks with nothing, so the creature deals 3 combat damage to Chandra (removing 3 loyalty counters). Simultaneously, you gain 3 life from lifelink.
There are no conditions on this interaction — lifelink always applies when the creature deals damage, including to planeswalkers, players, or other creatures.
Unofficial fan resource — not affiliated with or endorsed by Wizards of the Coast. Answers are AI-generated estimates grounded in the Comprehensive Rules and are not a substitute for an official judge. Verify anything match-critical.