Sanji and Luffy had both mentors who made great sacrifices for them (Shanks gave up his left arm to save Luffy, and Zeff gave up his right leg for Sanji), and ultimately gave them the motivation to believe that they could achieve their dream.
Sanji and Luffy have a great trust in each other as seen most recently when Luffy trusted Sanji to fight off Big Mom and travel all the way to Zou while protecting Caesar, Momonosuke and the rest of the crew from all danger. Sanji succeeded and Luffy was confident Sanji could look after himself even when the cook was missing from Zou, but Luffy became concerned when he learnt that Sanji had gotten entangled in a Yonko’s political plans, and decided to go retrieve him from his “wedding” to Pudding.
When Charlotte Cracker told Luffy that Sanji would most likely be happy with the Charlotte Family and turn away from the Straw Hats, Luffy angrily attacked him telling him not to put words in Sanji’s mouth.
When Sanji actually said what Cracker said to Luffy, directly, after violently kicking Luffy off the Cat Carriage, and then telling him to begone, Luffy immediately expressed his doubt over Sanji’s words as being sincere.
After being freed by Jinbe, while storming the palace, Luffy was found by Reiju, who informed him that Sanji has become aware of Pudding’s true nature, much to Luffy’s relief. Luffy then learns the reason for Sanji’s actions before returning to the place where Luffy promised to wait for Sanji.
In the same way, Sanji could not forgo his care for his captain, as when Bobbin tried to eat the Meat (meant for Luffy) from Sanji’s Bento box, Sanji became enraged and kicked down the pirate- inadvertently risking Zeff ‘s life in process.This worth noting as Sanji almost never denies anybody food, but cared more for his starving captain than keeping his deal with the Big Mom Pirates. Sanji traveled through Sweet City and soon found his captain at the spot that he promised to meet with him which brought to his face.
Just as he did with Nami and Chopper at Punk Hazard, Luffy understood when a decision was important to Sanji, and decided to support that decision. Sanji gave his reasons as to why he could not return to the crew and was punched in the face by Luffy, who told him to admit the truth and Sanji told him that while he is conflicted over wanting to save his family despite their cruel treatment, he nonetheless wanted to return to the crew and Luffy complimented that Sanji is truly kindhearted and he will help him ruin the wedding ceremony.