Breast milk making him gassy

My LO is 8 weeks. Im breastfeeding him with occasional formula top up. Say thrice a week or so.

Everyday around 6 pm he starts crying ... An would continue to 11pm. He latches unlatches fusses at the breast and cries. More like screams. Putting him in his front on my thigh helps. He makes his body rigid and just cries. Some time he just refuses formula and wants the boob

He is gaining weight but not as much. He was 4.8kg today. He is gaining good height thought.

Everyday is exhausting with the crying, I feel i am failing and my milk is making his gassy and he isn't putting on enough. I'm often tempted to just switch to formula cause it might help with both issues. But in all honesty I like breastfeeding him, it makes me feel special but I'm struggling.

What do I eat to make milk nutritious? And not gassy. How do I not give up?