Hi Aman,
If you want an open source developer friendly phone that has a lot of custom roms and resources available then obviously go for oneplus. Its a great device all in all with amazing specs and battery life. The hardware is all present and perfectly functional. If you do not like anything software wise you can always change it installing a custom rom.
Moto X also has its own developer community support, you can browse it on XDA. However, I've seen Oneplus having the maximum amount custom roms prepped and also I noticed that the latest and greatest features are brought to Oneplus pretty quickly by devs. That being said the dev community is still strong for MotoX as well. One thing about oneplus though is that as its a dev friendly phone you shud be ready to deal with minor bugs and search to resolve.
If you are okay with these small issues you will get one of the best experiences.
Note : Proud owner of a Oneplus One which is running TugaPower based off Android Nougat. Even after 2 years its running strong without any issues. I haven't experienced what lag is in the past two years and trust me I've put this phone through a lot of abuse
Feel free to connect with me know if you have any questions.
Best,
Akshat