This was bugging me for months until I took some time to figure it out.
In case your QuickLook function on Mac OS X 10.11 or up stops previewing plain text files — and only plain text files —, don't depair. Just remove the
QLColorCode generator from
~/Library/QuickLook and exchange it for an updated one that actually works. Afterwards run
qlmanage -r to reload all generators.
I found out that the
QLColorCode generator hijacks
public.plain-text by running
qlmanage -m | grep text. Since code highlighting wasn't working for quite some time I figured this might be the reason text preview also fails. Which turned out to be true.
All other solutions I found on the web did not work.