Hydrogen embrittlement (HE) seriously restricts the service safety of structural metallic materials applicate in aerospace, ocean, and transportation. Recent studies aiming at increasing the HE-resistance have been focusing on trapping diffusible H atoms by inherent microstructural features in materials. Alloying-induced compositional complexities, including different types of solute atoms, lattice chemical heterogeneities, and carbide precipitates, have attracted research efforts regarding the H trapping capabilities and potential to reduce the susceptibility to HE. In this paper, we review recent progress in exploiting compositional complexities to regulate the hydrogen trapping characteristics and mechanical properties in H-containing environments. The focus is placed on results and insights from ab initio calculations based on density functional theory (DFT). Quantitative predictions of trapping parameters and atomic scale details that are hardly to be gained through traditional experimental characterizations are provided. Additionally, we overview the electronic/atomistic mechanisms of H trapping energetics in metallic materials. Finally, we propose some key challenges and prospects in simulation of defect interactions, interpretation of experimental characterizations, and developing microstructure-based H diffusion prediction models. For the applications of first principle calculations, we illustrate how the DFT data can complement experimental characterizations to guide composition and microstructure design for better HE-resistant materials.