Hello and hope you are doing well.
Your symptoms of moving your legs in sleep could be due to a sleep disorder called Periodic Limb Movement Disorder (PLMD). They disrupt sleep and cause involuntary movements during sleep. The cause is not known. They can be diagnosed with a sleep study and medications help to control them. Follow good sleep hygiene measures like going to bed at the same time, waking up at the same time, avoidance of alcohol, smoking and caffeinated beverages. This will help to reduce the occurrence of your symptoms. Please consult your primary care physician if problem persists.
Hope this helped and do keep us posted.
Chronic Insomnia merely means you've had difficulty sleeping longer than 3 months. The cause of shaking when you sleep very much depends on the type of shaking, when you do it, and the associated features. If the "shaking" was just a single "jerk" intermittently while falling asleep, this is likely just hypnic jerks. If your legs jerk for much of the night while asleep, this could be related to Periodic Leg Movements (which is sometimes but not always associated with Restless Leg Syndrome). Seizures can also causing shaking at night but it would be unusual to wake up immediately afterwards and not be confused or have other symptoms related to seizures. Finally, panic attacks are frequent at night and sometimes anxiety can cause shaking episodes.