1" Command to check for the presence of a feature. 2command -nargs=1 CheckFeature call CheckFeature(<f-args>) 3func CheckFeature(name) 4 if !has(a:name) 5 throw 'Skipped: ' .. a:name .. ' feature missing' 6 endif 7endfunc 8 9" Command to check for the presence of a working option. 10command -nargs=1 CheckOption call CheckOption(<f-args>) 11func CheckOption(name) 12 if !exists('+' .. a:name) 13 throw 'Skipped: ' .. a:name .. ' option not supported' 14 endif 15endfunc 16 17" Command to check for the presence of a function. 18command -nargs=1 CheckFunction call CheckFunction(<f-args>) 19func CheckFunction(name) 20 if !exists('*' .. a:name) 21 throw 'Skipped: ' .. a:name .. ' function missing' 22 endif 23endfunc 24 25" Command to check for the presence of an Ex command 26command -nargs=1 CheckCommand call CheckCommand(<f-args>) 27func CheckCommand(name) 28 if !exists(':' .. a:name) 29 throw 'Skipped: ' .. a:name .. ' command not supported' 30 endif 31endfunc 32 33" Command to check for the presence of a shell command 34command -nargs=1 CheckExecutable call CheckExecutable(<f-args>) 35func CheckExecutable(name) 36 if !executable(a:name) 37 throw 'Skipped: ' .. a:name .. ' program not executable' 38 endif 39endfunc 40 41" Command to check for running on MS-Windows 42command CheckMSWindows call CheckMSWindows() 43func CheckMSWindows() 44 if !has('win32') 45 throw 'Skipped: only works on MS-Windows' 46 endif 47endfunc 48 49" Command to check for NOT running on MS-Windows 50command CheckNotMSWindows call CheckNotMSWindows() 51func CheckNotMSWindows() 52 if has('win32') 53 throw 'Skipped: does not work on MS-Windows' 54 endif 55endfunc 56 57" Command to check for running on Unix 58command CheckUnix call CheckUnix() 59func CheckUnix() 60 if !has('unix') 61 throw 'Skipped: only works on Unix' 62 endif 63endfunc 64 65" Command to check that making screendumps is supported. 66" Caller must source screendump.vim 67command CheckScreendump call CheckScreendump() 68func CheckScreendump() 69 if !CanRunVimInTerminal() 70 throw 'Skipped: cannot make screendumps' 71 endif 72endfunc 73 74" Command to check that we can Run Vim in a terminal window 75command CheckRunVimInTerminal call CheckRunVimInTerminal() 76func CheckRunVimInTerminal() 77 if !CanRunVimInTerminal() 78 throw 'Skipped: cannot run Vim in a terminal window' 79 endif 80endfunc 81 82" Command to check that we can run the GUI 83command CheckCanRunGui call CheckCanRunGui() 84func CheckCanRunGui() 85 if !has('gui') || ($DISPLAY == "" && !has('gui_running')) 86 throw 'Skipped: cannot start the GUI' 87 endif 88endfunc 89 90" Command to check that we are using the GUI 91command CheckGui call CheckGui() 92func CheckGui() 93 if !has('gui_running') 94 throw 'Skipped: only works in the GUI' 95 endif 96endfunc 97 98" Command to check that not currently using the GUI 99command CheckNotGui call CheckNotGui() 100func CheckNotGui() 101 if has('gui_running') 102 throw 'Skipped: only works in the terminal' 103 endif 104endfunc 105