Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d3f9a89

Browse files
committed
Add xolox#misc#os#find_vim() function
1 parent 5812878 commit d3f9a89

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

‎autoload/xolox/misc/compat.vim‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
" scripts breaks backwards compatibility. This enables my Vim plug-ins to fail
1313
" early when they detect an incompatible version, instead of breaking at the
1414
" worst possible moments :-).
15-
let g:xolox#misc#compat#version = 8
15+
let g:xolox#misc#compat#version = 9
1616

1717
" Remember the directory where the miscellaneous scripts are loaded from
1818
" so the user knows which plug-in to update if incompatibilities arise.

‎autoload/xolox/misc/os.vim‎

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,45 @@
11
" Operating system interfaces.
22
"
33
" Author: Peter Odding <peter@peterodding.com>
4-
" Last Change: May 19, 2013
4+
" Last Change: May 20, 2013
55
" URL: http://peterodding.com/code/vim/misc/
66

7-
let g:xolox#misc#os#version = '0.3'
7+
let g:xolox#misc#os#version = '0.4'
88

99
function! xolox#misc#os#is_win() " {{{1
1010
" Returns 1 (true) when on Microsoft Windows, 0 (false) otherwise.
1111
return has('win16') || has('win32') || has('win64')
1212
endfunction
1313

14+
function! xolox#misc#os#find_vim() " {{{1
15+
" Returns the program name of Vim as a string. On Windows and UNIX this
16+
" simply returns [v:progname] [progname] while on Mac OS X there is some
17+
" special magic to find MacVim's executable even though it's usually not on
18+
" the executable search path.
19+
"
20+
" [progname]: http://vimdoc.sourceforge.net/htmldoc/eval.html#v:progname
21+
let progname = ''
22+
if has('macunix')
23+
" Special handling for Mac OS X where MacVim is usually not on the $PATH.
24+
call xolox#misc#msg#debug("os.vim %s: Trying MacVim workaround to find Vim executable ..", g:xolox#misc#os#version)
25+
let segments = xolox#misc#path#split($VIMRUNTIME)
26+
if segments[-3:] == ['Resources', 'vim', 'runtime']
27+
let progname = xolox#misc#path#join(segments[0:-4] + ['MacOS', 'Vim'])
28+
call xolox#misc#msg#debug("os.vim %s: The MacVim workaround resulted in the Vim executable %s.", g:xolox#misc#os#version, string(progname))
29+
endif
30+
endif
31+
if empty(progname)
32+
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))
33+
let candidates = xolox#misc#path#which(v:progname)
34+
if !empty(candidates)
35+
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))
36+
let progname = candidates[0]
37+
endif
38+
endif
39+
call xolox#misc#msg#debug("os.vim %s: Reporting Vim executable %s.", g:xolox#misc#os#version, string(progname))
40+
return progname
41+
endfunction
42+
1443
function! xolox#misc#os#exec(options) " {{{1
1544
" Execute an external command (hiding the console on Microsoft Windows when
1645
" my [vim-shell plug-in] [vim-shell] is installed).

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /