We present a first-principle study of electronic and optical properties in pure LiF and O-doped LiF crystals. The pure LiF crystal exhibits a wide band gap while the O-doped LiF crystal shows the less band gap due to the contribution of O 2p. Some optical constants, such as dielectric functions, reflectivity and the refractive index, have been performed. The calculated reflectivity and refractive index from the pure LiF crystal agree with the experimental and recently calculated results in the low-energy range. Meanwhile, the optical properties have also been predicted from the O-doped LiF crystal. The absorption band in 200 nm has been observed, which is relatively close to the experimental result.