An (aza)indole derivative substituted in position 5, of formula (I): in which X, Y, Z, G1, G2, G3, R1, W, and R2 have the meanings given in the description, a pharmaceutical composition comprising it, and also intermediate compounds and a preparation process therefor.