lifepillar / vim-colortemplate

The Toolkit for Vim Color Scheme Designers!
929 stars 29 forks source link

Handling multiple palettes in a single template for a given background #70

Closed prateektade closed 1 year ago

prateektade commented 1 year ago

I am trying to port the Rosé Pine colorscheme to Vim using your awesome tool. It has two palette versions for dark background and one for a white background. I used the following code to handle the dark palettes -

#if  get(g:, 'rose_pine_moon', 0)
    Color: color1 rgb(x, y, z) ~
    ....
#else
    Color: color1 rgb(a, b, c) ~
    ....
#endif

When I build the template, I get the error Color already defined for dark background.

I looked through the documentation and the Gruvbox port you made, but I was not able to find any existing implementation. Is there any way for handling these multiple palettes using a single template?

lifepillar commented 1 year ago

You cannot define colors conditionally: #if is used only to define highlight groups conditionally. Colortemplate only allows one palette for dark and one, independent, palette for light background (so, you may have one color1 for dark and one color1 for light). What you are trying to do can be achieved in this way:

Color: color1     rgb(x, y, z) ~
Color: color1alt  rgb(a, b, c) ~

#if get(g: 'rose_pine_moon', 0)
  HiGroup1 color1 …
  HiGroup2 color1 …
#else
  HiGroup1 color1alt …
  HiGroup2 color1alt …
#endif
lifepillar commented 1 year ago

You may also consider splitting your color scheme into two distinct color schemes (or three if you also want a separate light theme), and get rid of the configuration variable. For users it may be more convenient to choose between, say, rose_pine_dark, rose_pine_softdark, and rose_pine_light rather than setting a variable in their vimrc, or the background.

You might create two or three templates, one per color scheme, and use the Include directive to include the common parts from a separate file. Then, using BuildAll you may build all of your color schemes at once.

prateektade commented 1 year ago

Thank you for your prompt response and this brilliant tool! I ended up creating three separate templates for each flavor like you suggested and that's working perfectly well. The lightline template also came in pretty handy. The error and warning messages were pretty clear for a total programming and Vimscript noob like me.

Thanks again!