Skip to content

Commit

Permalink
Version 1.3: Added checks for required vim version and features
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Hodge authored and vim-scripts committed Oct 18, 2010
1 parent 84e718f commit 9936c26
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions plugin/AfterColors.vim
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
" Vim Plugin: AfterColors.vim:
" Provides: Automatic sourcing of after/colors/ scripts.
" Author: Peter Hodge <toomuchphp-vim@yahoo.com>
" Version: 1.2
" Last Update: November 27, 2006
" URL: http://www.vim.org/scripts/script.php?script_id=1641
" Version: 1.3
" Last Update: May 13, 2008
" Requires: Vim 6 or later (preferably 7) with autocommand support
"
"
" Minor Bug: if you just add your 'after/colors' scripts to
" 'vimfiles/after/colors/myColorsName.vim', when you go to
Expand All @@ -27,24 +30,32 @@
" 5 - vimfiles/plugins/[more plugins]
" 6 - vimfiles/after_colors/myColorsName.vim

" requires vim 6 at least
if version <= 600 || exists('loaded_AfterColors') || ! has("autocmd")
finish
endif

let g:loaded_AfterColors = 1

" provide ability for an 'after/colors' file using autocommands
augroup AfterColorsPlugin
autocmd!

" source the 'after' colors scripts only after vim has finished everything
" else, because there are many things which will reset the colors
autocmd VimEnter * call s:AfterColorsScript()
if exists('##VimEnter')
autocmd VimEnter * call <SID>AfterColorsScript()
endif

" if this vim has the 'Colorscheme' event, we can hook onto it to ensure
" that the 'after' colors are reloaded when the colorscheme is changed
if exists('##ColorScheme')
autocmd ColorScheme * call s:AfterColorsScript()
autocmd ColorScheme * call <SID>AfterColorsScript()
endif

augroup end

function! s:AfterColorsScript()
function! <SID>AfterColorsScript()
if exists('g:colors_name') && strlen(g:colors_name)
" allow two places to store after/colors scripts
execute 'runtime! after/colors/' . g:colors_name . '.vim'
Expand Down

0 comments on commit 9936c26

Please sign in to comment.