Skip to content

Commit

Permalink
Make it possible to exclude color schemes in $VIMRUNTIME/colors
Browse files Browse the repository at this point in the history
(suggested by Arun Subramanian in private e-mail)
  • Loading branch information
xolox committed Nov 19, 2014
1 parent 689c86b commit 03ed734
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ A list with names of color schemes to be ignored by the plug-in. By default the

:let g:colorscheme_switcher_exclude = ['default', 'test']

### The `g:colorscheme_switcher_exclude_builtins` option

If you set this variable to 1 (true) the color schemes bundled with Vim (installed in `$VIMRUNTIME`) are ignored and instead only the color schemes that you specifically installed in your Vim profile are used.

### The `g:colorscheme_switcher_command` option

This option is a string specifying the Vim command used to switch between color schemes. It defaults to the [:colorscheme] [cs] command. You can set this option to integrate the vim-colorscheme-switcher plug-in with other plug-ins like [colorsupport.vim](https://github.com/vim-scripts/colorsupport.vim) and [guicolorscheme.vim](https://github.com/vim-scripts/guicolorscheme.vim).
Expand Down
19 changes: 12 additions & 7 deletions autoload/xolox/colorscheme_switcher.vim
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
" Vim plug-in
" Maintainer: Peter Odding <peter@peterodding.com>
" Last Change: June 25, 2014
" Last Change: November 19, 2014
" URL: http://peterodding.com/code/vim/colorscheme-switcher

let g:xolox#colorscheme_switcher#version = '0.4.1'
let g:xolox#colorscheme_switcher#version = '0.5'

" Dictionary with previously seen links between highlighting groups.
if !exists('s:known_links')
Expand Down Expand Up @@ -60,15 +60,20 @@ endfunction

function! xolox#colorscheme_switcher#find_names() " {{{1
" Get a sorted list with the available color schemes.
let list = []
let matches = {}
let exclude_list = xolox#misc#option#get('colorscheme_switcher_exclude', [])
let exclude_builtins = xolox#misc#option#get('colorscheme_switcher_exclude_builtins', 0)
for fname in split(globpath(&runtimepath, 'colors/*.vim'), '\n')
let name = fnamemodify(fname, ':t:r')
let exclude = xolox#misc#option#get('colorscheme_switcher_exclude', [])
if index(list, name) == -1 && index(exclude, name) == -1
call add(list, name)
" Ignore names in the exclude list.
if index(exclude_list, name) == -1
" Ignore color schemes bundled with Vim?
if !(exclude_builtins && xolox#misc#path#starts_with(fname, $VIMRUNTIME))
let matches[name] = 1
endif
endif
endfor
return sort(list, 1)
return sort(keys(matches), 1)
endfunction

function! xolox#colorscheme_switcher#find_links() " {{{1
Expand Down
10 changes: 9 additions & 1 deletion doc/colorscheme-switcher.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ Contents ~
1. The |g:colorscheme_switcher_define_mappings| option
2. The |g:colorscheme_switcher_keep_background| option
3. The |g:colorscheme_switcher_exclude| option
4. The |g:colorscheme_switcher_command| option
4. The |g:colorscheme_switcher_exclude_builtins| option
5. The |g:colorscheme_switcher_command| option
5. See also |colorscheme-switcher-see-also|
6. Known problems |colorscheme-switcher-known-problems|
7. Contact |colorscheme-switcher-contact|
Expand Down Expand Up @@ -112,6 +113,13 @@ list is empty. Here's an example of how you can set this:
>
:let g:colorscheme_switcher_exclude = ['default', 'test']
<
-------------------------------------------------------------------------------
The *g:colorscheme_switcher_exclude_builtins* option

If you set this variable to 1 (true) the color schemes bundled with Vim
(installed in '$VIMRUNTIME') are ignored and instead only the color schemes
that you specifically installed in your Vim profile are used.

-------------------------------------------------------------------------------
The *g:colorscheme_switcher_command* option

Expand Down

0 comments on commit 03ed734

Please sign in to comment.