A spectral approach to Yang--Mills theory