I get more nightmares when I eat before I go to sleep... I'd say physical discomfort causes nightmares but it's not necessarily the only reason to get them...
I usually only have nightmares when I go to bed anxious about something. And I don't even remember them afterwards, which is weird, but I know I woke up from one because of that terrible feeling etc.