The present work proposes to use density-functional theory (DFT) to correct for the basis-set error of wave-function theory (WFT). One of the key ideas developed here is to define a range-separation parameter which automatically adapts to a given basis set. The derivation of the exact equations are based on the Levy-Lieb formulation of DFT, which helps us to define a complementary functional which corrects uniquely for the basis-set error of WFT. The coupling of DFT and WFT is done through the definition of a real-space representation of the electron-electron Coulomb operator projected in a one-particle basis set. Such an effective interaction has the particularity to coincide with the exact electron-electron interaction in the limit of a complete basis set, and to be finite at the electron-electron coalescence point when the basis set is incomplete. The non-diverging character of the effective interaction allows one to define a mapping with the long-range interaction used in the context of range-separated DFT and to design practical approximations for the unknown complementary functional. Here, a local-density approximation is proposed for both full-configuration-interaction (FCI) and selected configuration-interaction approaches. Our theory is numerically tested to compute total energies and ionization potentials for a series of atomic systems. The results clearly show that the DFT correction drastically improves the basis-set convergence of both the total energies and the energy differences. For instance, a sub kcal/mol accuracy is obtained from the aug-cc-pVTZ basis set with the method proposed here when an aug-cc-pV5Z basis set barely reaches such a level of accuracy at the near FCI level.