Doom Emacs has editor/fold module which makes folding code simple

Steps:

Demo (folding a large hash in ruby):

fold ruby code