By means of ab initio calculations, we study the electronic structure of LiFeSO4F, which has been shown recently [N. Recham et al., Nature Mater. 9, 68 (2010)] to be an excellent material as a cathode for lithium-ion batteries. We have obtained the crystal structure of FeSO4F, which was not completely determined experimentally, and compare the one of LiFeSO4F to available experimental values, resolving the issue about the position of the Li ion. Our calculated intercalation voltage (3.69 V) is found to be in excellent agreement with experiments. Finally, we have studied LiCoSO4F and LiNiSO4F, which are found to share a similar crystal structure with LiFeSO4F.