The professor I do research with often puts me down for making mistakes and frequently calls me an idiot. I don't know the appropriate way to respond. I cannot just leave, since I still want to go to grad school. But this is severely affecting my mental health, and I have been suicidal recently as a result. I put a lot of effort into trying to be positive and friendly around him, but I'm not sure this has been particularly effective.
The research I do with him is good in a technical sense; we have some solid results and have published at very good conferences together. He has agreed to write me a good letter of recommendation (but actually hasn't written it yet) and I believe him if only because he seems to care strongly about his reputation among his peers and writing me a poor letter would reflect badly on him. I do not know what to do.