Depends on what exactly is meant by "imminent attack." Did they have intel that Iranian proxies were going to attack XYZ on Tuesday, January 7 at 3:00 PM? I doubt it. Did they suspect he was up to something, perhaps something bigger and more coordinated than previous attacks, given he'd been hopping between Iraq, Syria, and Lebanon lately? Probably. The frequency of his travel had increased lately.
Having said that, I don't think this was spur-of-the-moment at all. Obviously they had been tracking him and knew his whereabouts. Both Dubya and Obama passed on the opportunity to take him out; a targeted killing of him is something that was on "a list" for years. An assassination of Soleimani was on a list of potential responses that was presented to Trump, along with a bunch of other things.