\def\mylstwd{.55em}
\lstdefinelanguage{expkv}[primitive]{TeX}
  {
    ,moretexcs=[2]% e-TeX
      {
        expanded,
        numexpr,
        protected,
        unexpanded,
        ifdefined,
        detokenize,
      }
    ,moretexcs=[3]% plain/LaTeX/ConTeXt
      {
        approx,
        begin,end,
        cdot,
        emph,empty,
        item,
        LaTeX,
        makeatletter,makeatother,multicolumn,
        newcommand,renewcommand,newdimen,newif,newcount,NewDocumentCommand,
        usepackage,RequirePackage,ProvidesPackage,
        raggedright,
        rule,
        space,stop,
        smallskip,medskip,bigskip,
        TeX,
        textit,texttt,
        usepackage,
        usemodule,
        @gobble,@gobbletwo,@firstofone,@empty,@firstoftwo,@secondoftwo,
        ExplSyntaxOn,ExplSyntaxOff,
      }
    ,moretexcs=[4]% used packages
      {
        % xfp
        fpeval,
        % keyval
        setkeys,
        % kvsetkeys
        kvsetkeys,
        % color
        textcolor,
        % yax
        defactiveparameter,storevalue,setparameterlist,
        % graphics
        includegraphics,
      }
    ,moretexcs=[5]% expkv macros
      {
        ekvdef,ekvdefNoVal,%
        ekvlet,ekvletNoVal,ekvletkv,ekvletkvNoVal,%
        ekvdefunknown,ekvdefunknownNoVal,%
        ekvletunknown,ekvletunknownNoVal,%
        ekvredirectunknown,ekvredirectunknownNoVal,%
        ekvset,ekvsetSneaked,%
        ekvsetdef,ekvsetSneakeddef,ekvsetdefSneaked,%
        ekvcompile,%
        ekvparse,%
        ekvVersion,ekvDate,%
        ekvifdefined,ekvifdefinedNoVal,ekvifdefinedset,%
        ekvbreak,ekvbreakPreSneak,ekvbreakPostSneak,%
        ekvsneak,ekvsneakPre,%
        ekvchangeset,%
        ekvmorekv,%
        ekvoptarg,ekvoptargTF,%
        ekvcsvloop,%
        ekverr,%
        ekv@name,%
      }
    ,moretexcs=[6]% expkv-cs macros
      {
        ekvcSecondaryKeys,%
        ekvcSplit,ekvcSplitAndForward,ekvcSplitAndUse,%
        ekvcHash,ekvcHashAndForward,ekvcHashAndUse,%
        ekvcValue,ekvcValueFast,ekvcValueSplit,ekvcValueSplitFast,%
        ekvcChange,%
        ekvcPass,%
      }
    ,moretexcs=[7]% expkv-def macros
      {
        ekvdefinekeys
      }
    ,moretexcs=[8]% expkv-pop macros
      {
        ekvpNewParser,
        ekvpDefType,
        ekvpDefPrefix,ekvpDefAutoPrefix,ekvpDefPrefixStore,ekvpDefPrefixLet,
        ekvpLet,
        ekvpValueAlwaysRequired,ekvpDefNoValue,ekvpUseNoValueMarker,
        ekvpDefNoValuePrefix,ekvpDefNoType,ekvpDefNoValue,
        ekvpEOP,ekvpGobbleP,ekvpEOT,ekvpGobbleT,ekvpEOA,ekvpGobbleA,
        ekvpIfNoVal,
        ekvpAssertIf,ekvpAssertIfNot,ekvpAssertTF,ekvpAssertTFNot,
        ekvpAssertValue,ekvpAssertNoValue,
        ekvpAssertOneValue,ekvpAssertTwoValues,
        ekvpParse,
      }
    ,moretexcs=[9]% expkv-opt macros
      {
        ekvoProcessOptions,%
        ekvoProcessLocalOptions,ekvoProcessGlobalOptions,%
        ekvoProcessFutureOptions,ekvoProcessOptionsList,%
        ekvoUseUnknownHandlers,%
        ekvoVersion,ekvoDate,%
      }
    ,alsoletter={_:}
    ,moretexcs=[10]% expl3
      {
        cs_new_eq:NN,
        tl_count_tokens:n,
      }
  }
\colorlet{codeparam}{cyan!65!black}
\lstdefinestyle{expkv}
  {
     texcsstyle=*[5]{\bfseries\color{ekvred}}  % expkv
    ,texcsstyle=*[6]{\color{ekvred}}           % expkv-cs
    ,texcsstyle=*[7]{\color{ekvred}}           % expkv-def
    ,texcsstyle=*[8]{\color{ekvred}}           % expkv-pop
    ,texcsstyle=*[9]{\color{ekvred}}           % expkv-opt
  }
\lstdefinestyle{expkv-cs}
  {
     texcsstyle=*[5]{\color{ekvred}}           % expkv
    ,texcsstyle=*[6]{\bfseries\color{ekvred}}  % expkv-cs
    ,texcsstyle=*[7]{\color{ekvred}}           % expkv-def
    ,texcsstyle=*[8]{\color{ekvred}}           % expkv-pop
    ,texcsstyle=*[9]{\color{ekvred}}           % expkv-opt
  }
\lstdefinestyle{expkv-def}
  {
     texcsstyle=*[5]{\color{ekvred}}           % expkv
    ,texcsstyle=*[6]{\color{ekvred}}           % expkv-cs
    ,texcsstyle=*[7]{\bfseries\color{ekvred}}  % expkv-def
    ,texcsstyle=*[8]{\color{ekvred}}           % expkv-pop
    ,texcsstyle=*[9]{\color{ekvred}}           % expkv-opt
  }
\lstdefinestyle{expkv-pop}
  {
     texcsstyle=*[5]{\color{ekvred}}           % expkv
    ,texcsstyle=*[6]{\color{ekvred}}           % expkv-cs
    ,texcsstyle=*[7]{\color{ekvred}}           % expkv-def
    ,texcsstyle=*[8]{\bfseries\color{ekvred}}  % expkv-pop
    ,texcsstyle=*[9]{\color{ekvred}}           % expkv-opt
  }
\lstdefinestyle{expkv-opt}
  {
     texcsstyle=*[5]{\color{ekvred}}           % expkv
    ,texcsstyle=*[6]{\color{ekvred}}           % expkv-cs
    ,texcsstyle=*[7]{\color{ekvred}}           % expkv-def
    ,texcsstyle=*[8]{\color{ekvred}}           % expkv-pop
    ,texcsstyle=*[9]{\bfseries\color{ekvred}}  % expkv-opt
  }
\lstdefinestyle{expkv-all}
  {
     texcsstyle=*[5]{\bfseries\color{ekvred}}  % expkv
    ,texcsstyle=*[6]{\bfseries\color{ekvred}}  % expkv-cs
    ,texcsstyle=*[7]{\bfseries\color{ekvred}}  % expkv-def
    ,texcsstyle=*[8]{\bfseries\color{ekvred}}  % expkv-pop
    ,texcsstyle=*[9]{\bfseries\color{ekvred}}  % expkv-opt
  }
\lstset
  {
    ,language=expkv
    ,style=expkv
    ,flexiblecolumns=false
    ,basewidth=\mylstwd
    %,basicstyle=\fontfamily{lmtt}\selectfont
    %,basicstyle=\fontfamily{GoMono-TLF}\selectfont%\itshape
    %,basicstyle=\fontfamily{jkp}\selectfont%\itshape
    %,basicstyle=\fontfamily{jkptt}\selectfont%\itshape
    ,basicstyle=\fontfamily{txtt}\selectfont%\itshape
    ,texcsstyle=*[1]{\bfseries\color{ekvgrey}} % primitives
    ,texcsstyle=*[2]{\bfseries\color{ekvgrey}} % e-TeX
    ,texcsstyle=*[3]{\bfseries\color{ekvgrey}} % plain/LaTeX macros
    ,texcsstyle=*[4]{\bfseries\color{ekvgrey}} % macros of other packages
    ,texcsstyle=*[10]{\bfseries\color{ekvgrey}} % macros of expl3
    ,commentstyle=\color[gray]{0.4}
    ,literate=
              {\{} {{\CodeUpBf\{}}{1}
              {\}} {{\CodeUpBf\}}}{1}
              {$}  {{\CodeUpBf\$}}{1}
              {[}  {{\CodeUp[}}{1}
              {]}  {{\CodeUp]}}{1}
              {(}  {{\CodeUp(}}{1}
              {)}  {{\CodeUp)}}{1}
              {*}  {{$*$}}{1}
              {1}  {{\CodeUp{1}}}{1}
              {2}  {{\CodeUp{2}}}{1}
              {3}  {{\CodeUp{3}}}{1}
              {4}  {{\CodeUp{4}}}{1}
              {5}  {{\CodeUp{5}}}{1}
              {6}  {{\CodeUp{6}}}{1}
              {7}  {{\CodeUp{7}}}{1}
              {8}  {{\CodeUp{8}}}{1}
              {9}  {{\CodeUp{9}}}{1}
              {0}  {{\CodeUp{0}}}{1}
              {##} {{\CodeColored{codeparam}{1}{\#}}}{1}
              {##1}{{\CodeColored{codeparam}{2}{\#1}}}{2}
              {##2}{{\CodeColored{codeparam}{2}{\#2}}}{2}
              {##3}{{\CodeColored{codeparam}{2}{\#3}}}{2}
              {##4}{{\CodeColored{codeparam}{2}{\#4}}}{2}
              {##5}{{\CodeColored{codeparam}{2}{\#5}}}{2}
              {##6}{{\CodeColored{codeparam}{2}{\#6}}}{2}
              {##7}{{\CodeColored{codeparam}{2}{\#7}}}{2}
              {##8}{{\CodeColored{codeparam}{2}{\#8}}}{2}
              {##9}{{\CodeColored{codeparam}{2}{\#9}}}{2}
              {<key>}{{$\langle$}key{$\rangle$}}{5}
              {<set>}{{$\langle$}set{$\rangle$}}{5}
              {<set1>}{{$\langle$}set1{$\rangle$}}{6}
              {<set2>}{{$\langle$}set2{$\rangle$}}{6}
    %,literate=*{<key>}{\key}{4}{<set>}{\set}{4}
  }
\newcommand*\CodeColored[3]{\textcolor{#1}{\makebox[\dimexpr\mylstwd*#2]{#3}}}
\newcommand*\CodeUpBf[1]{\makebox[\mylstwd]{\textup{\textbf{#1}}}}
\newcommand*\CodeUp[1]{\makebox[\mylstwd]{\textup{#1}}}
