A systematic study of geometries, formation energies, and electronic structures has been carried out for LiF considering monodoping with Mg and Ti at the interstitial, and lattice site positions, codoping in equal and different proportions, and vacancy defects in absence and presence of foreign elements using hybrid density functional. This study reveals that, both Mg and Ti, show preference for the Li lattice sites over interstitial sites. Li-poor condition is energetically more preferable over Li-rich condition, and codoping is found to be more stable over individual doping. Under this condition, formation of Li-vacancy in codoped system is found to be spontaneous. The presence of only Li vacancy results negligible changes on LiF electronic structure. Interestingly, in presence of Mg, and Ti, it plays an important role by modifying the band gap. Present results provide important insights to tune optical properties of LiF through the rational design of defect-controlled synthetic conditions.