So, I had experienced something similar and fix was two fold - first, it turned out I had anemia and needed to fix health stuff. So, that would be first round, take a look at own health in general.
Second, lifestyle. Oddly enough, keeping super strict schedule (only for a while unless you are naturally routine person) separating work and other time helped. Make sure other time involves sport and activities nor related to coding at all. Learning counts as work time, but also make sure work is work (and not HN or reddit).
The second thing helped to restore motivation. After a while, I started to look forward coding again, started to want to do it.
Second, lifestyle. Oddly enough, keeping super strict schedule (only for a while unless you are naturally routine person) separating work and other time helped. Make sure other time involves sport and activities nor related to coding at all. Learning counts as work time, but also make sure work is work (and not HN or reddit).
The second thing helped to restore motivation. After a while, I started to look forward coding again, started to want to do it.