CSApprox : Make gvim-only colorschemes work transparently in terminal vim
| script karma
Downloaded by 19718
Comments, bugs, improvements
script versions (upload new version)
It's hard to find colorschemes for terminal Vim. Most colorschemes are
written to only support GVim, and don't work at all in terminal Vim.
This plugin makes GVim-only colorschemes Just Work in terminal Vim, as long
as the terminal supports 88 or 256 colors - and most do these days. This
usually requires no user interaction (but see the help for what to do if
things don't Just Work). After getting this plugin happily installed, any
time you use :colorscheme it will do its magic and make the colorscheme Just
Whenever you change colorschemes using the :colorscheme command this script
will be executed. It will take the colors that the scheme specified for use
in the GUI and use an approximation algorithm to try to gracefully degrade
them to the closest color available in your terminal. If you are running in
a GUI or if your terminal doesn't support 88 or 256 colors, no changes are
made. Also, no changes will be made if the colorscheme seems to have been
high color already.
If for some reason this transparent method isn't suitable to you (for instance
if your environment can't be configured to meet the |csapprox-requirements|,
or you need to work in Vim 6), another option is also available: using the
|:CSApproxSnapshot| command to create a new GUI/88-/256-color terminal
colorscheme. To use this command, a user would generally start GVim, choose a
colorscheme that sets up the desired colors, and then use |:CSApproxSnapshot|
to create a new colorscheme based on those colors that works in high color
terminals. This method is more flexible than the transparent mode and works
in more places, but also requires more user intervention, and makes it harder
to deal with colorschemes being updated and such.
Ideally, this plugin should require absolutely no configuration, but you may
need some tweaking to make sure vim realizes that your terminal supports more
than 16 colors. Also, konsole and Eterm users will want to make sure that
this plugin realizes that the terminal does not use colors that are exactly
xterm-compatible; they will want to skim through the help articles
|csapprox-palettes| and |csapprox-configuration| for a better end result.
Some quick side-by-side screenshots can be found at
|Install like most other vim scripts:
vim -c 'helptags ~/.vim/doc'
Click on the package to download.
ip used for rating: 184.108.40.206
||Fix CSApprox to not fail in vim 7.3 if not +gui, now that vim behaves properly even without +gui
Provide the :CSApprox command to re-run CSApprox's approximation algorithm even if the colorscheme hasn't changed - useful for when the user has tweaked some colors manually.
Better handling for the inverse (aka reverse) attribute for terminals that actually support it - and add the g:CSApprox_fake_reverse config variable to allow switching back to the old behavior for terminals that don't support real reverse video.
Fix an issue where CSApprox would unconditionally leave 'background' set to "light" - now it will leave 'background' unchanged when it runs.
Change the handling for Konsole to use the xterm palette by for KDE versions >= 2.2.0 - Konsole itself was changed to drop its old, slightly incompatible palette in KDE 2.2.0
Fix a minor issue where running vim in recovery mode with -r would result in a complaint from CSApprox that the terminal didn't have enough colors even when it did.
Fix an issue where, even if CSApprox had been disabled by setting g:CSApprox_loaded, a CSApprox error message could still be displayed.
||Fix a major regression that prevented the Eterm and Konsole colors from being correctly snapshotted
Fix a related bug causing incorrect terminal colors after calling :CSApproxSnapshot
Fix a bug causing black to be used instead of dark grey
Have snapshots calculate g:colors_name programmatically
Introduce many tweaks for better speed
Clarify some things at :help csapprox-terminal-example
Default to using our own list of rgb.txt colors rather than searching, for performance. Add a new variable, g:CSApprox_use_showrgb, which forces us to try finding the colors using the "showrgb" program instead, and fall back on our own list if it isn't available
Remove g:CSApprox_extra_rgb_txt_dirs - not needed in light of the above change
||Fix a harmless "Undefined variable" error in :CSApproxSnapshot
Fix a behavioral bug when dumping out colors defined external to the scheme.
||Update the docs for better info on :CSApproxSnapshot
Allow snapshotted schemes to work on Vim 6, and work properly in Konsole and Eterm (thanks David Majnemer!)
Fix a bug causing a syntax error when using GVim while CSApprox was loaded. (thanks again, David Majnemer!)
||Add a hooks system, allowing users to specify a command to run, either before or after the approximation algorithm is run, for all schemes or one specific one.
Also rewrite :CSApproxSnapshot to be more maintainable and less of a hack, and fix several bugs that it contained.
||Add :CSApproxSnapshot for writing out a colorscheme file representing the current colors that will work in gvim, 88 color vim, or 256 color vim, even without +gui. See :help :CSApproxSnapshot
||Distribute an rgb.txt along with CSApprox, so that CSApprox can still be used on distributions where no rgb.txt is provided with the X server (like Ubuntu Intrepid Ibex). Thanks to Penn Su for finding this!