In a heavy-bottomed Dutch oven or big pot, heat the oil over medium flame, then gently sauté the onions until they start to become translucent—6 or 7 minutes.
Add the garlic and ginger, and keep sautéing until the garlic starts to turn golden, about 2 more minutes. Then stir in the garam masala and the cayenne and sauté everything together for another 1 or 2 minutes.
Stir in the coconut milk to blend everything. Then add the red lentils, the water and the shredded coconut. Give everything a good stir. Add the salt, stir again, bring it all to a boil, then reduce the heat and simmer.
Stir the soup now and then—I set a timer and stirred it about every 5 or 6 minutes. You want the lentils to soften and start to break down, which will take around half an hour. When the soup reaches that point, add the spinach and the tomatoes all at once. Stir and cook a few more minutes.
Taste; adjust the salt and add more cayenne pepper if you like. To serve, ladle into bowls. If you like, top with a dollop of whole-milk yogurt or, if you want a vegan dish, a nondairy yogurt—or nothing at all.