Set b:undo_ftplugin for matchpairs, matchit variables, b:syng_str and the foldexpr settings, and b:undo_indent for indent settings, instead of relying on whichever indent file was loaded last.