Manga about a student having nightmares Hi I'm trying to find the manga I've read some time ago. I forgot the title.

There's this teenage kid who was having nightmares about cats, Then there is this army of cats that chased him then he met this magical girl (I forgot her powers) and I think the source of her power relies on her hat. After meeting together, There is this master of cats who's weapon is a chainsaw? Also, the dimension of the nightmare activates when the protagonist tries to sleep.

I probably forgot the rest because of an exam that I had to study for a long time.
This would be Dream Eater Merry (Yumekui Merry) 

The scene you are talking about is the first scene of the anime where Yumeji Fujiwara, the main character, is running away from cats in a nightmare he is having. The next time he has the dream, he encounters the leader called "Chaser" John Doe who wields a chainsaw.



After trying to escape, Fujiwara encounters a girl called Merry Nightmare who ends up fighting John.

.

Both Merry and John are Dream Demons from another world, and Dream Demons can possess people's bodies to enter the real world. However, Merry has no memories and she doesn't need to possess a body.

As for Merry's powers sourcing from her hat, I don't think this is the case. Rather, I think she just really, really, really loves her had. (I haven't seen the series in a while, but I think I remember her being able to fight without her hat).

As for the dimension of the nightmares, these are actually just people's dreams which Merry can enter and drag Fujiwara into. Other humans who appear in dreams are either possessed by a Dream Demon who has entered the dream (i.e. "Garden" Engi Threepiece) or own the dream themselves.

This video shows the scene of Fujiwara meeting John Doe.

While what I describe is from the anime, there is a manga (the original material) and I believe the beginning of the manga would be the same.