adityam / filter

ConTeXt module to process contents of a start-stop environment through an external program
45 stars 10 forks source link

t-vim Create custom color schemes #28

Closed JulianGmp closed 4 years ago

JulianGmp commented 5 years ago

Disclaimer: I'm fairly new to ConTeXt, I have done some LaTeX, though I don't know much about TeX development. So this is probably possible but I just don't know how.

I've recently started to play around with the vim module for displaying code in a fancy way, and it's working really well.

However, I would like to customize the colour scheme for my document, preferably without modifying the module files themselves.

I imagine the \startcolorscheme[...] command does this in in the module, though I'm not sure how easily that could be used.

From t-vim.tex line 280

\startcolorscheme[pscolor]
    % Vim Preferred groups
    \definesyntaxgroup
        [Constant]
        [\c!color={h=007068}]

    \definesyntaxgroup
        [Identifier]
[\c!color={h=a030a0}]
.....
\stopcolorscheme
adityam commented 5 years ago

To define a new colorscheme say JulianGmp, add the following lines to you file:

\startcolorscheme[JulianGmp]
    \definesyntaxgroup
        [Constant]

    \definesyntaxgroup
        [Identifier]

    \definesyntaxgroup
        [Statement]

    \definesyntaxgroup
        [PreProc]

    \definesyntaxgroup
        [Type]

    \definesyntaxgroup
        [Special]

    \definesyntaxgroup
        [Comment]

    \definesyntaxgroup
         [Ignore]

    \definesyntaxgroup
        [Todo]

    \definesyntaxgroup
        [Error]

    \definesyntaxgroup
        [Underlined]

    \setups{vim-minor-groups}
\stopcolorscheme

Each of these elements accept three arguments:

\definesyntaxgroup
   [...]
   [
      color={...},
      style={...}, 
      command={...},
   ]

The values to the color scheme can be a predefined ConTeXt color, or a hex code (specified as h=XXXXXX).

The value to style can be any be any style specifier for style key in ConTeXt such as bold, italic, bolditalic, etc.

The value to command can be any macro that takes one argument.

Hope this clarifies how to create a new colorscheme. I'll try to add a more detailed page on the documentation about it.

adityam commented 4 years ago

Closed by commit bd7292c