Hey there. You probably already know a lot of this but I find it always helps. I don't think I've ever been as severe as you in your post but I have been through times where I start doubting my mind and losing the plot a bit and this is what helps me:
Sleep:
If you can't sleep at night don't force it. Get out of bed and go and do something productive: Draw, Read, Study... anything to take your mind of things without stimulating your brain too much (I find video games, TV etc can be a bad thing).
Try listening to a talk radio show on whilst you're trying to get you asleep. It will get your mind off things a bit. It helps me sleep!
If you don't sleep well or at all in the night still get up at a normal time and just plough through the day. Don't nap or let yourself drift off. Then go to a bed at a normal time and try and develop a regular sleeping pattern. Say - Bed at 11 up at half 7 every single day.
Do exercise in the day so that your body is physically tired. This will help you want to sleep more.
If you still have problems maybe your doc can prescribe something to help you drift off?
Exercise and Eating Healthy
Exercise is so so so good at helping me feel better and I think it is the same for a lot of people. It releases feel good chemicals and gives you a sense of accomplishment after completing exercise. This will also help with your sleep. It also eases stress and I find relaxes my muscles. After a run I feel much happier and less anxious.
Eating at regular times is so important. Keep the flow regular with small snacks in between. This will keep you going all day and won't leave you feel energyless when you stop eating and get out of sync with things.
Drink lots of water - when I don't drink enough I start getting demotivated and groggy. Also try taking some multivitamins.
Other Stuff
Talk to anyone you can about it. Don't bottle anything up. Let it all out. If I don't have anyone to talk to about stuff - I write it down in a note pad. Better out than in my Mum says!
Keep productive - Do things each day that are mentally stimulating
If you go to work school college or uni just make yourself go. It will give you sense of routine.
--------
You probably already know all this stuff like and I don't want to sound patronising or like ordering in anyway or whatever but I hope it helps
But these are things I try and implement all the time but I motivate myself especially hard to do these things when I get into mental rutts! Things start to get much clearer when I do the above and helps me get out of them.