I find that if too much liquid is involved with legume-rich meals, I get a "hurricane" D-attack (example food: lentil soup): watery going in for me = watery going out. Goodness forbid if spices are involved !
I do great with tvp, tofu, seitan and quorn for protein bases. Lentils are troublesome for me, probably due to the high insoluble fiber content. They just move thru me too rapidly. Kidney beans are much less troublesome for me than lentils. Black beans are favourable for me, but they have a solid percentage of soluble fiber. Edammame are highly friendly foods and most every kind of pea (split pea, frozen pea, sugar snap pea, chick pea, etc.).
When I order lentil daal at an Indian restaurant, I am guaranteed bad/painful gas due to the way my body handles lentils, however if I order channa masala with rice I'm okay. I guess you just have to listen to your body.