I've had chronic insomnia for nine years, and I can safely say that diet is related! Low carb is a disaster for me. 150g carbs a day should be okay though. Are you eating enough food in general? Low calorie is pretty detrimental to my sleep too.
Also, be careful of the melatonin. I was taking it regularly but then I read about some negative side effects. I'll look it up...
"I think the basic anti-aging diet is also the best diet for prevention and treatment of diabetes, scleroderma, and the various "connective tissue diseases." This would emphasize high protein, low unsaturated fats, low iron, and high antioxidant consumption, with a moderate or low starch consumption.
In practice, this means that a major part of the diet should be milk, cheese, eggs, shellfish, fruits and coconut oil, with vitamin E and salt as the safest supplements."
- Ray Peat