Permalink
Browse files

Define version as variable, include version in messages

  • Loading branch information...
1 parent 4be4d28 commit 6c11e2791f8bdb8ce6e90482a09b99f2277e2a7b @xolox committed Jun 18, 2011
Showing with 30 additions and 26 deletions.
  1. +6 −8 autoload/xolox/reload.vim
  2. +13 −15 doc/reload.txt
  3. +11 −3 plugin/reload.vim
View
@@ -1,10 +1,8 @@
" Vim script
-" Last Change: February 4, 2011
+" Last Change: June 18, 2011
" Author: Peter Odding
" URL: http://peterodding.com/code/vim/reload/
-let s:script = expand('<sfile>:t')
-
" Patterns to match various types of Vim script names. {{{1
" Enable line continuation.
@@ -69,14 +67,14 @@ function! s:reload_plugin(start_time, filename, friendly_name) " {{{1
call s:reload_message('plug-in', a:friendly_name)
unlet! g:loaded_{fnamemodify(a:filename, ':t:r')}
execute 'source' fnameescape(a:filename)
- return ["%s: Reloaded %s plug-in in %s.", s:script, a:friendly_name, a:start_time]
+ return ["reload.vim %s: Reloaded %s plug-in in %s.", g:reload_version, a:friendly_name, a:start_time]
endfunction
if !exists('s:reload_script_active')
function! s:reload_autoload(start_time, filename, friendly_name) " {{{1
call s:reload_message('auto-load script', a:friendly_name)
execute 'source' fnameescape(a:filename)
- return ["%s: Reloaded %s auto-load script in %s.", s:script, a:friendly_name, a:start_time]
+ return ["reload.vim %s: Reloaded %s auto-load script in %s.", g:reload_version, a:friendly_name, a:start_time]
endfunction
endif
@@ -107,7 +105,7 @@ function! s:reload_buffers(start_time, filetype, friendly_name, script_type, var
call winrestview(view_save)
" Disable the SwapExists automatic command.
unlet s:reloading_buffers
- return ["%s: Reloaded %s %s in %s.", s:script, a:script_type, a:friendly_name, a:start_time]
+ return ["reload.vim %s: Reloaded %s %s in %s.", g:reload_version, a:script_type, a:friendly_name, a:start_time]
endfunction
function! xolox#reload#open_readonly() " {{{1
@@ -150,7 +148,7 @@ function! s:reload_colors(start_time, filename, friendly_name) " {{{1
let escaped = fnameescape(colorscheme)
execute 'colorscheme' escaped
execute 'doautocmd colorscheme' escaped
- return ["%s: Reloaded %s color scheme in %s.", s:script, a:friendly_name, a:start_time]
+ return ["reload.vim %s: Reloaded %s color scheme in %s.", g:reload_version, a:friendly_name, a:start_time]
endif
endfunction
@@ -190,7 +188,7 @@ function! s:normalize_path(path) " {{{2
endfunction
function! s:reload_message(scripttype, scriptname) " {{{2
- call xolox#misc#msg#info('%s: Reloading %s %s', s:script, a:scripttype, a:scriptname)
+ call xolox#misc#msg#info('reload.vim %s: Reloading %s %s.', g:reload_version, a:scripttype, a:scriptname)
endfunction
" vim: ts=2 sw=2 et
View
@@ -32,7 +32,7 @@ The directories listed above are Vim's defaults but you're free to change the
Note that |vimrc| scripts are not reloaded because that seems to cause more
trouble than it's worth...
-==============================================================================
+===============================================================================
*reload-install-first-use*
Install & first use ~
@@ -49,9 +49,8 @@ all Vim scripts that it knows how to. If you like it this way then you don't
need to configure anything! However if you don't like the automatic reloading
then you'll need the following:
-------------------------------------------------------------------------------
- *g:reload_on_write-option*
-The 'g:reload_on_write' option ~
+-------------------------------------------------------------------------------
+The *g:reload_on_write* option
If you don't like automatic reloading because it slows Vim down or causes
problems you can add the following line to your |vimrc| script:
@@ -61,11 +60,10 @@ problems you can add the following line to your |vimrc| script:
This disables automatic reloading which means you'll have to reload scripts
using the command discussed below.
-------------------------------------------------------------------------------
- *:reloadscript-command*
-The ':ReloadScript' command ~
+-------------------------------------------------------------------------------
+The *:ReloadScript* command
-You can execute the ':ReloadScript' command to reload the Vim script you're
+You can execute the |:ReloadScript| command to reload the Vim script you're
editing. If you provide a script name as argument to the command then that
script will be reloaded instead, e.g.:
>
@@ -75,15 +73,15 @@ If after executing this command you see Vim errors such as "Function already
exists" (|E122|) or "Command already exists" (|E174|) then you'll need to change
your Vim script(s) slightly to enable reloading, see below.
-==============================================================================
+===============================================================================
*things-that-prevent-reloading*
Things that prevent reloading ~
If you want your Vim plug-ins and/or other scripts to be automatically
reloaded they'll have to be written a certain way, though you can consider the
following points good practice for Vim script writing anyway:
-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
Use a bang in command and function definitions! ~
Function and command definitions using Vim's |:command| and |:function| built-ins
@@ -100,7 +98,7 @@ complain that the command or function already exists:
:function! MyFun()
:endfunction
-------------------------------------------------------------------------------
+-------------------------------------------------------------------------------
*reload-use-automatic-command-groups*
Use automatic command groups ~
@@ -119,7 +117,7 @@ several times:
: autocmd! TabEnter * echomsg "Entered tab page"
:augroup END
-==============================================================================
+===============================================================================
*reload-alternatives*
Alternatives ~
@@ -134,7 +132,7 @@ scripts, but there are a few notable differences:
- This plug-in can more or less reload itself ;-)
-==============================================================================
+===============================================================================
*reload-contact*
Contact ~
@@ -143,14 +141,14 @@ contacted at peter@peterodding.com. The latest version is available at
http://peterodding.com/code/vim/reload/ and http://github.com/xolox/vim-reload.
If you like the plug-in please vote for it on Vim Online [3].
-==============================================================================
+===============================================================================
*reload-license*
License ~
This software is licensed under the MIT license [4]. Copyright 2010 Peter
Odding <peter@peterodding.com>.
-==============================================================================
+===============================================================================
*reload-references*
References ~
View
@@ -1,13 +1,18 @@
" Vim script
-" Last Change: May 25, 2011
+" Last Change: June 18, 2011
" Author: Peter Odding
" URL: http://peterodding.com/code/vim/reload/
-" License: MIT
-" Version: 0.6.1
" Support for automatic update using the GLVS plug-in.
" GetLatestVimScripts: 3148 1 :AutoInstall: reload.zip
+" Don't source the plug-in when it's already been loaded or &compatible is set.
+if &cp || exists('g:loaded_reload')
+ finish
+endif
+
+let g:reload_version = '0.6.2'
+
if !exists('g:reload_on_write')
let g:reload_on_write = 1
endif
@@ -40,4 +45,7 @@ if !exists('s:auto_reload_active')
endfunction
endif
+" Don't reload the plug-in once it has loaded successfully.
+let g:loaded_reload = 1
+
" vim: ts=2 sw=2 et

0 comments on commit 6c11e27

Please sign in to comment.