sponsor Vim development Vim logo Vim Book Ad

colorsupport.vim : Use colorschemes written for gvim in color terminals.

 script karma  Rating 82/24, Downloaded by 2788    Comments, bugs, improvements  Vim wiki

created by
JiHwan Lee
 
script type
utility
 
description
colorsupport.vim
================
Use colorschemes written for gvim in color terminals.
Tested with many colorschemes including color sampler pack (vimscript #625)

To set up a 256-color terminal, see

- http://push.cx/2008/256-color-xterms-in-ubuntu
- http://robotsrule.us/vim/

And don't forget to rate ;^)

Simple usage
------------
- Drop 'colorsupport.vim' in '~/.vim/plugin'.

  At next startup, colorscheme loaded by '.vimrc' will be reloaded with gui
  colors mapped to terminal palette.  That is, if you already have gvim
  colorscheme set in '~/.vimrc', then it'll work as soon as you install the
  'colorsupport.vim' script.

- Browse and preview colorschemes in your &runtimepath by
  ':ColorSchemeBrowse'.  You can also manually try colorschemes using
  ':ColorScheme', just like ':colorscheme'.

- On slow systems, it can take long to convert colorscheme every time vim
  starts up.  For faster start-up, save last colorscheme by ':ColorSchemeSave'.

  By default, this saves last colorscheme loaded by ':ColorScheme' in the first
  &runtimepath (usually, ~/.vim/colors on Unix).

  If last colorscheme is already from '~/.vim/colors', error will occur,  and
  you should use ':ColorSchemeSave <new-colorscheme-name>' instead.

Upgrade
-------
When upgrading colorsupport.vim, additional color groups can be set,
but color schemes saved by :ColorSchemeSave passes conversion by :ColorScheme.
Delete old (converted and saved) color schemes if you want re-convert.

Customization
-------------
- g:colorsupport_palette_name (one of "tango" (default), "console", "xterm", "rxvt")
- g:colorsupport_palette (e.g., ['#000000',  ...]. (length better be =16))

- g:colorsupport_cube_name (one of "xterm256", "xterm88", "konsole", "eterm")
- g:colorsupport_cube (e.g. [0x00, 0x2A, 0x55, 0xAA, 0xD4])

- g:colorsupport_grey (e.g., range(0x1C, 0xFF, 30))

- g:colorsupport_rgbs (e.g., ['/usr/X11/share/X11'])

Keep {len(g:colorsupport_palette) + len(g:colorsupport_cube)^3 + len(g:colorsupport_grey) == &t_Co}

Commands
--------
- Highlight ...

  Arguments are the same as :highlight
  Set 'cterm', 'ctermfg', 'ctermbg' based on 'gui', 'guifg', 'guibg',
  respectively.  Note that given 'cterm.*' settings are ignored.

- ColorScheme <path-or-name>

  Load a colorscheme using ':Highlight', instead of ':highlight'.
  Unlike colorscheme, path is accepted as well as colorscheme name.

- ColorSchemeBrowse [<path>]

  Browse colorschemes in <path> (or &runtimepath, if no arguments given)

- ColorSchemeSave [<name>]

  Save last colorscheme loaded by ':ColorScheme' (or, equivalently, browsed by
  ':ColorSchemeViewer') in the first &runtimepath.  If <name> is not given,
  original name of last colorscheme is used.


Comparison
----------
At the time that I uploaded this script, I was unaware of other color conversion scripts.
And I've tried them later.

vimscript #2390. (Thank you marty)

Key difference is that vimscript #2390 practically requires gvim installed.
And major difficulty (and dirty tricks) of this script was to get gui
attributes from colorschemes, which are not obtainable from series of
synIDxxx() functions without +gui feature.  

vimscript #1809

vimscript #1809 tries to extract hilight information by string match.
(I assume that this approach is what most conversion script have took)
By contrast, colorsupport.vim actually run the original color scheme
with highlight command substituted with Highlight command.
Later works better because many color schemes have highlights
in conditional block, which should not be extracted.

Furthermore, vimscript #1809 does not support color names.
 
install details
mv colorsupport.vim ~/.vim/plugin
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
colorsupport.vim 1.0.5 2013-10-20 7.0 JiHwan Lee - Fix a bug that ignores background setting.
- Fix an error which happens when colorscheme does not set g:colors_name.
colorsupport.vim 1.0.4 2013-10-17 7.0 JiHwan Lee Bug fix:
- Use NONE instead of none for transparent gui color to avoid gvim errors.
- Fix an issue that wrong colors (especially background colors) are chosen.
colorsupport.vim 1.0.3 2011-01-22 7.0 JiHwan Lee minor improvements and bug fixes, including
- handles "hilight" with bang(!)
- fix a bug that g:colors_name goes wrong when &background set after g:colors_name
- lazy load script variables for faster start-up
colorsupport.vim 1.0.2 2009-06-25 7.0 JiHwan Lee Added hard-coded default color groups.
Map guisp to ctermbg.
colorsupport.vim 1.0.1 2009-06-17 7.0 JiHwan Lee Added konsole and eterm color cube.
Generalize user customization.
colorsupport.vim 1.0 2009-06-16 7.0 JiHwan Lee Initial upload
ip used for rating: 54.81.53.224

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
SourceForge.net Logo