We present a first-principles technique for investigating the electron-phonon interaction with millions of k points in the Brillouin zone, which exploits the spatial localization of electronic and lattice Wannier functions. We demonstrate the effectiveness of our technique by elucidating the phonon mechanism responsible for superconductivity in boron-doped diamond. Our calculated phonon self-energy and Eliashberg spectral function show that superconductivity cannot be explained without taking into account the finite-wave-vector Fourier components of the vibrational modes introduced by boron, as well as the breaking of the diamond crystal periodicity induced by doping.