Permalink
Browse files

Make sure vim-misc is installed, politely complain if it isn't

  • Loading branch information...
xolox committed Aug 19, 2013
1 parent afeefed commit 487260a5f34bf2ba7972f67fd9b570cefa0bbc1a
Showing with 66 additions and 53 deletions.
  1. +1 −0 addon-info.json
  2. +2 −2 autoload/xolox/colorscheme_switcher.vim
  3. +46 −48 doc/colorscheme-switcher.txt
  4. +17 −3 plugin/colorscheme-switcher.vim
View
@@ -0,0 +1 @@
+{"vim_script_nr": 4586, "dependencies": {"vim-misc": {}}, "homepage": "http://peterodding.com/code/vim/colorscheme-switcher", "name": "vim-colorscheme-switcher"}
@@ -1,9 +1,9 @@
" Vim plug-in
" Maintainer: Peter Odding <peter@peterodding.com>
-" Last Change: May 25, 2013
+" Last Change: August 19, 2013
" URL: http://peterodding.com/code/vim/colorscheme-switcher
-let g:xolox#colorscheme_switcher#version = '0.2.4'
+let g:xolox#colorscheme_switcher#version = '0.2.5'
" Dictionary with previously seen links between highlighting groups.
if !exists('s:known_links')
@@ -1,43 +1,43 @@
*colorscheme-switcher.txt* Color scheme switcher for Vim
===============================================================================
- *colorscheme-switcher-contents*
Contents ~
- 1. Introduction |colorscheme-switcher-introduction|
- 2. Installation |colorscheme-switcher-installation|
- 3. Commands |colorscheme-switcher-commands|
+ 1. Introduction |colorscheme-switcher-introduction|
+ 2. Installation |colorscheme-switcher-installation|
+ 3. Commands |colorscheme-switcher-commands|
1. The |:NextColorScheme| command
2. The |:PrevColorScheme| command
- 4. Options |colorscheme-switcher-options|
+ 4. Options |colorscheme-switcher-options|
1. The |g:colorscheme_switcher_define_mappings| option
2. The |g:colorscheme_switcher_keep_background| option
3. The |g:colorscheme_switcher_exclude| option
- 5. Known problems |colorscheme-switcher-known-problems|
- 6. Contact |colorscheme-switcher-contact|
- 7. License |colorscheme-switcher-license|
+ 5. Known problems |colorscheme-switcher-known-problems|
+ 6. Contact |colorscheme-switcher-contact|
+ 7. License |colorscheme-switcher-license|
+ 8. References |colorscheme-switcher-references|
===============================================================================
- *colorscheme-switcher-introduction*
+ *colorscheme-switcher-introduction*
Introduction ~
The colorscheme switcher plug-in for the Vim text editor makes it easy to
quickly switch between colorschemes (see |:colorscheme|). It defines commands
and mappings to switch to the next and previous color schemes.
===============================================================================
- *colorscheme-switcher-installation*
+ *colorscheme-switcher-installation*
Installation ~
-Please note that the vim-colorscheme-switcher plug-in requires my vim-misc
-plug-in which is separately distributed.
+_Please note that the vim-colorscheme-switcher plug-in requires my vim-misc
+plug-in which is separately distributed._
-Unzip the most recent ZIP archives of the vim-colorscheme-switcher [1] and
-vim-misc [2] plug-ins inside your Vim profile directory (usually this is
-'~/.vim' on UNIX and '%USERPROFILE%\vimfiles' on Windows), restart Vim and
-execute the command ':helptags ~/.vim/doc' (use ':helptags ~\vimfiles\doc'
-instead on Windows). Now try it out: Execute |:NextColorScheme| to switch to
-the next color scheme.
+Unzip the most recent ZIP archives of the vim-colorscheme-switcher [1] and vim-
+misc [2] plug-ins inside your Vim profile directory (usually this is '~/.vim'
+on UNIX and '%USERPROFILE%\vimfiles' on Windows), restart Vim and execute the
+command ':helptags ~/.vim/doc' (use ':helptags ~\vimfiles\doc' instead on
+Windows). Now try it out: Execute |:NextColorScheme| to switch to the next
+color scheme.
If you didn't change the plug-in's configuration you can now use the 'F8' and
'Shift-F8' keys to switch to the next/previous color scheme.
@@ -47,7 +47,7 @@ install & update the vim-colorscheme-switcher [5] and vim-misc [6] plug-ins
using a local clone of the git repository.
===============================================================================
- *colorscheme-switcher-commands*
+ *colorscheme-switcher-commands*
Commands ~
-------------------------------------------------------------------------------
@@ -63,24 +63,23 @@ Switch to the previous color scheme. After the first color scheme the cycle
repeats from the last color scheme.
===============================================================================
- *colorscheme-switcher-options*
+ *colorscheme-switcher-options*
Options ~
-The colorscheme switcher plug-in should work out of the box, but you can
-change the configuration defaults if you want to change how the plug-in works.
+The colorscheme switcher plug-in should work out of the box, but you can change
+the configuration defaults if you want to change how the plug-in works.
-------------------------------------------------------------------------------
The *g:colorscheme_switcher_define_mappings* option
By default the plug-in maps the following keys in insert and normal mode:
- - 'F8' switches to the next color scheme
-
- - 'Shift-F8' switches to the previous color scheme
+- 'F8' switches to the next color scheme
+- 'Shift-F8' switches to the previous color scheme
To disable these mappings (e.g. because you're already using them for a
-different purpose) you can set the option |g:colorscheme_switcher_define_mappings|
-to 0 (false) in your |vimrc| script.
+different purpose) you can set the option
+|g:colorscheme_switcher_define_mappings| to 0 (false) in your |vimrc| script.
-------------------------------------------------------------------------------
The *g:colorscheme_switcher_keep_background* option
@@ -96,41 +95,40 @@ it's late at night (then you'll likely prefer a dark background).
-------------------------------------------------------------------------------
The *g:colorscheme_switcher_exclude* option
-A list with names of color schemes to be ignored by the plug-in. By default
-the list is empty. Here's an example of how you can set this:
+A list with names of color schemes to be ignored by the plug-in. By default the
+list is empty. Here's an example of how you can set this:
>
- :let g:colorscheme_switcher_exclude = ['default', 'test']
-
+ :let g:colorscheme_switcher_exclude = ['default', 'test']
+<
===============================================================================
- *colorscheme-switcher-known-problems*
+ *colorscheme-switcher-known-problems*
Known problems ~
The way Vim color schemes are written isn't really compatible with the idea of
quickly switching between lots of color schemes. In my opinion this is an ugly
implementation detail of how Vim works internally, in other words I think it's
-a bug that should be fixed... Here are some references that explain the
-problem in some detail:
-
- - Vim colorscheme leaves a wake of destruction when switching away [7]
+a bug that should be fixed... Here are some references that explain the problem
+in some detail:
- - gVim: remove syntax highlighting groups [8]
+- Vim colorscheme leaves a wake of destruction when switching away [7]
+- gVim: remove syntax highlighting groups [8]
Since this behavior hinders cycling through color schemes, the colorscheme
switcher plug-in includes a workaround that should hide the problem:
- - At startup a dictionary is created which will be used to remember links
+1. At startup a dictionary is created which will be used to remember links
between highlighting groups;
- - Before and after loading a color scheme, the colorscheme switcher plug-in
+2. Before and after loading a color scheme, the colorscheme switcher plug-in
runs the |:highlight| command without any arguments to find links between
highlighting groups. Each link that is found is added to the dictionary.
Existing entries are updated. This is done by calling
'xolox#colorscheme_switcher#find_links()'.
- - After loading a color scheme, the colorscheme switcher plug-in runs the
- |:highlight| command without any arguments to find highlighting groups in the
- state 'cleared'. For each of these groups, if they were previously linked,
- the link is restored. This is done by calling
+3. After loading a color scheme, the colorscheme switcher plug-in runs the
+ |:highlight| command without any arguments to find highlighting groups in
+ the state 'cleared'. For each of these groups, if they were previously
+ linked, the link is restored. This is done by calling
'xolox#colorscheme_switcher#restore_links()'.
Probably this solution is still not perfect, but it's a lot better than the
@@ -140,7 +138,7 @@ a white background and nothing else! With the steps above, I can cycle as many
times as I want and all of the color schemes I've checked so far look fine.
===============================================================================
- *colorscheme-switcher-contact*
+ *colorscheme-switcher-contact*
Contact ~
If you have questions, bug reports, suggestions, etc. the author can be
@@ -150,14 +148,14 @@ http://github.com/xolox/vim-colorscheme-switcher. If you like this plug-in
please vote for it on Vim Online [9].
===============================================================================
- *colorscheme-switcher-license*
+ *colorscheme-switcher-license*
License ~
-This software is licensed under the MIT license [10]. Copyright 2013 Peter
-Odding <peter@peterodding.com>.
+This software is licensed under the MIT license [10]. Š 2013 Peter Odding
+<peter@peterodding.com>.
===============================================================================
- *colorscheme-switcher-references*
+ *colorscheme-switcher-references*
References ~
[1] http://peterodding.com/code/vim/downloads/colorscheme-switcher.zip
@@ -1,17 +1,28 @@
" Vim plug-in
" Maintainer: Peter Odding <peter@peterodding.com>
-" Last Change: May 18, 2013
+" Last Change: August 19, 2013
" URL: http://peterodding.com/code/vim/colorscheme-switcher
" This Vim plug-in defines two commands and four key mappings to quickly
" switch between color schemes (with the same &background if so desired).
if &cp || exists('g:loaded_colorscheme_switcher')
finish
-else
- let g:loaded_colorscheme_switcher = 1
endif
+" Make sure vim-misc is installed.
+try
+ " The point of this code is to do something completely innocent while making
+ " sure the vim-misc plug-in is installed. We specifically don't use Vim's
+ " exists() function because it doesn't load auto-load scripts that haven't
+ " already been loaded yet (last tested on Vim 7.3).
+ call type(g:xolox#misc#version)
+catch
+ echomsg "Warning: The vim-colorscheme-switcher plug-in requires the vim-misc plug-in which seems not to be installed! For more information please review the installation instructions in the readme (also available on the homepage and on GitHub). The vim-colorscheme-switcher plug-in will now be disabled."
+ let g:loaded_colorscheme_switcher = 1
+ finish
+endtry
+
" You can set this variable to 0 (false) in your vimrc script to disable the
" default mappings (F8 in insert and normal mode).
if !exists('g:colorscheme_switcher_define_mappings')
@@ -42,4 +53,7 @@ endif
command! -bar -bang NextColorScheme call xolox#colorscheme_switcher#next()
command! -bar -bang PrevColorScheme call xolox#colorscheme_switcher#previous()
+" Don't reload the plug-in once it has loaded successfully.
+let g:loaded_colorscheme_switcher = 1
+
" vim: ts=2 sw=2 et

0 comments on commit 487260a

Please sign in to comment.