I added the following code to my .vimrc:
\" save and restore folds when a file is closed and re-opened autocmd BufWinLeave *.* mkview autocmd BufWinEnter *.* sil
With Neovim in Arch Linux, I was getting error messages until I appended a ! after silent (silent!). Here is my ~/.vimrc entry,
autocmd BufWrite * mkview autocmd BufRead * silent! loadview
Details here:
https://github.com/neovim/neovim/issues/7442#issuecomment-339752054