aboutsummaryrefslogtreecommitdiffstats
path: root/autoload/xolox
diff options
context:
space:
mode:
authorPeter Odding <peter@peterodding.com>2013-05-20 14:00:59 +0200
committerPeter Odding <peter@peterodding.com>2013-05-20 14:00:59 +0200
commitd3f9a897819ded974886a40e51b64e30e5c75c57 (patch)
tree32063338cbbd345b691abcbd64228ae75f617087 /autoload/xolox
parent5812878c6c35ea37d2eae70c7276e37326ff058f (diff)
downloadvim-easytags-d3f9a897819ded974886a40e51b64e30e5c75c57.tar.gz
Add xolox#misc#os#find_vim() function
Diffstat (limited to 'autoload/xolox')
-rw-r--r--autoload/xolox/misc/compat.vim2
-rw-r--r--autoload/xolox/misc/os.vim33
2 files changed, 32 insertions, 3 deletions
diff --git a/autoload/xolox/misc/compat.vim b/autoload/xolox/misc/compat.vim
index e6c9a0c..b1fd30b 100644
--- a/autoload/xolox/misc/compat.vim
+++ b/autoload/xolox/misc/compat.vim
@@ -12,7 +12,7 @@
" scripts breaks backwards compatibility. This enables my Vim plug-ins to fail
" early when they detect an incompatible version, instead of breaking at the
" worst possible moments :-).
-let g:xolox#misc#compat#version = 8
+let g:xolox#misc#compat#version = 9
" Remember the directory where the miscellaneous scripts are loaded from
" so the user knows which plug-in to update if incompatibilities arise.
diff --git a/autoload/xolox/misc/os.vim b/autoload/xolox/misc/os.vim
index 157affe..9554947 100644
--- a/autoload/xolox/misc/os.vim
+++ b/autoload/xolox/misc/os.vim
@@ -1,16 +1,45 @@
" Operating system interfaces.
"
" Author: Peter Odding <peter@peterodding.com>
-" Last Change: May 19, 2013
+" Last Change: May 20, 2013
" URL: http://peterodding.com/code/vim/misc/
-let g:xolox#misc#os#version = '0.3'
+let g:xolox#misc#os#version = '0.4'
function! xolox#misc#os#is_win() " {{{1
" Returns 1 (true) when on Microsoft Windows, 0 (false) otherwise.
return has('win16') || has('win32') || has('win64')
endfunction
+function! xolox#misc#os#find_vim() " {{{1
+ " Returns the program name of Vim as a string. On Windows and UNIX this
+ " simply returns [v:progname] [progname] while on Mac OS X there is some
+ " special magic to find MacVim's executable even though it's usually not on
+ " the executable search path.
+ "
+ " [progname]: http://vimdoc.sourceforge.net/htmldoc/eval.html#v:progname
+ let progname = ''
+ if has('macunix')
+ " Special handling for Mac OS X where MacVim is usually not on the $PATH.
+ call xolox#misc#msg#debug("os.vim %s: Trying MacVim workaround to find Vim executable ..", g:xolox#misc#os#version)
+ let segments = xolox#misc#path#split($VIMRUNTIME)
+ if segments[-3:] == ['Resources', 'vim', 'runtime']
+ let progname = xolox#misc#path#join(segments[0:-4] + ['MacOS', 'Vim'])
+ call xolox#misc#msg#debug("os.vim %s: The MacVim workaround resulted in the Vim executable %s.", g:xolox#misc#os#version, string(progname))
+ endif
+ endif
+ if empty(progname)
+ call xolox#misc#msg#debug("os.vim %s: Looking for Vim executable named %s on search path ..", g:xolox#misc#os#version, string(v:progname))
+ let candidates = xolox#misc#path#which(v:progname)
+ if !empty(candidates)
+ call xolox#misc#msg#debug("os.vim %s: Found %i candidate(s) on search path: %s.", g:xolox#misc#os#version, len(candidates), string(candidates))
+ let progname = candidates[0]
+ endif
+ endif
+ call xolox#misc#msg#debug("os.vim %s: Reporting Vim executable %s.", g:xolox#misc#os#version, string(progname))
+ return progname
+endfunction
+
function! xolox#misc#os#exec(options) " {{{1
" Execute an external command (hiding the console on Microsoft Windows when
" my [vim-shell plug-in] [vim-shell] is installed).