The key is this:
Every occurrence of \[\033[38;5;Nm\] becomes simply %NF.
Every occurrence of \[$(tput sgr0)\] becomes simply %f.
\u, \h, \w, and \$ become %n, %m, %~, and %#.
And make sure that you have the PROMPT_PERCENT shell option turned on.
You do not need to export this shell variable.
The manual that you should be reading is zshmisc.
It looks like you need to define it in code2color. The documentation here lists the background.
Syntax highlighting of source code is possible through an included
script code2color which is derived from Peter Palfraders code2html
script or an external program (pygmentize). The script code2color is
written in perl and has colorizing support for the ...