In this work, we consider the generalized variable-coefficient nonlinear Schr{o}dinger equation with non-vanishing boundary conditions at infinity including the simple and double poles of the scattering coefficients. By introducing an appropriate Riemann surface and uniformization coordinate variable, we first convert the double-valued functions which occur in the process of direct scattering to single-value functions. Then, we establish the direct scattering problem via analyzing the analyticity, symmetries and asymptotic behaviors of Jost functions and scattering matrix derived from Lax pairs of the equation. Based on these results, a generalized Riemann-Hilbert problem is successfully established for the equation. The discrete spectrum and residual conditions, trace foumulae and theta conditions are investigated systematically including the simple poles case and double poles case. Moreover, the inverse scattering problem is solved via the Riemann-Hilbert approach. Finally, under the condition of reflection-less potentials, the soliton and breather solutions are well derived. Via evaluating the impact of each parameters, some interesting phenomena of these solutions are analyzed graphically.