Different colors for different keywords in listing environment doesn't work
Solution 1:
A very good answer was already given by user Symbol 1. Example language is in C++, but the way to style your code is the same:
Other keywords and symbols highlighting with lstlisting
\documentclass[10pt,a4paper]{scrartcl}
\usepackage{xcolor}
\definecolor{main-color}{rgb}{0.6627, 0.7176, 0.7764}
\definecolor{back-color}{rgb}{0.1686, 0.1686, 0.1686}
\definecolor{string-color}{rgb}{0.3333, 0.5254, 0.345}
\definecolor{key-color}{rgb}{0.8, 0.47, 0.196}
\usepackage{listings}
\lstdefinestyle{mystyle}
{
language = C++,
basicstyle = {\ttfamily \color{main-color}},
backgroundcolor = {\color{back-color}},
stringstyle = {\color{string-color}},
keywordstyle = {\color{key-color}},
keywordstyle = [2]{\color{lime}},
keywordstyle = [3]{\color{yellow}},
keywordstyle = [4]{\color{teal}},
otherkeywords = {;,<<,>>,++},
morekeywords = [2]{;},
morekeywords = [3]{<<, >>},
morekeywords = [4]{++},
}
\begin{document}
\begin{lstlisting}[firstnumber=1,language=C++, style=mystyle]
#include <iostream>
using namespace std;
int x = 2;
//comment
for (int i = 0; i < x; ++i) {
cout << "stand_alone_complex" << endl;
}
\end{lstlisting}
\end{document}