Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Updated miscellaneous scripts

  • Loading branch information...
commit 942f58a11ff7742b3873c0ea93c51a85c2c1dc03 2 parents dab5a33 + 8b60a41
Peter Odding authored May 20, 2013
4  autoload/xolox/luainspect.vim
@@ -3,9 +3,9 @@
3 3
 " Last Change: May 20, 2013
4 4
 " URL: http://peterodding.com/code/vim/lua-inspect/
5 5
 
6  
-let g:xolox#luainspect#version = '0.4.23'
  6
+let g:xolox#luainspect#version = '0.4.24'
7 7
 
8  
-call xolox#misc#compat#check('luainspect.vim', g:xolox#luainspect#version, 7)
  8
+call xolox#misc#compat#check('luainspect.vim', g:xolox#luainspect#version, 9)
9 9
 
10 10
 function! xolox#luainspect#toggle_cmd() " {{{1
11 11
   if !(exists('b:luainspect_disabled') && b:luainspect_disabled)
2  autoload/xolox/misc/compat.vim
@@ -12,7 +12,7 @@
12 12
 " scripts breaks backwards compatibility. This enables my Vim plug-ins to fail
13 13
 " early when they detect an incompatible version, instead of breaking at the
14 14
 " worst possible moments :-).
15  
-let g:xolox#misc#compat#version = 7
  15
+let g:xolox#misc#compat#version = 9
16 16
 
17 17
 " Remember the directory where the miscellaneous scripts are loaded from
18 18
 " so the user knows which plug-in to update if incompatibilities arise.
4  autoload/xolox/misc/msg.vim
... ...
@@ -1,7 +1,7 @@
1 1
 " Functions to interact with the user.
2 2
 "
3 3
 " Author: Peter Odding <peter@peterodding.com>
4  
-" Last Change: May 19, 2013
  4
+" Last Change: May 20, 2013
5 5
 " URL: http://peterodding.com/code/vim/misc/
6 6
 
7 7
 if !exists('g:xolox_message_buffer')
@@ -32,8 +32,6 @@ function! xolox#misc#msg#debug(...) " {{{1
32 32
   " increased verbosity by setting Vim's ['verbose'] [verbose] option to one
33 33
   " (1) or higher. This function has the same argument handling as Vim's
34 34
   " [printf()] [printf] function.
35  
-  "
36  
-  " [verbose]: http://vimdoc.sourceforge.net/htmldoc/options.html#'verbose'
37 35
   if &vbs >= 1
38 36
     call s:show_message('question', a:000)
39 37
   endif
37  autoload/xolox/misc/os.vim
... ...
@@ -1,16 +1,45 @@
1 1
 " Operating system interfaces.
2 2
 "
3 3
 " Author: Peter Odding <peter@peterodding.com>
4  
-" Last Change: May 19, 2013
  4
+" Last Change: May 20, 2013
5 5
 " URL: http://peterodding.com/code/vim/misc/
6 6
 
7  
-let g:xolox#misc#os#version = '0.3'
  7
+let g:xolox#misc#os#version = '0.4'
8 8
 
9 9
 function! xolox#misc#os#is_win() " {{{1
10 10
   " Returns 1 (true) when on Microsoft Windows, 0 (false) otherwise.
11 11
   return has('win16') || has('win32') || has('win64')
12 12
 endfunction
13 13
 
  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
+
14 43
 function! xolox#misc#os#exec(options) " {{{1
15 44
   " Execute an external command (hiding the console on Microsoft Windows when
16 45
   " my [vim-shell plug-in] [vim-shell] is installed).
@@ -63,9 +92,7 @@ function! xolox#misc#os#exec(options) " {{{1
63 92
     if !async
64 93
       let tempout = tempname()
65 94
       let temperr = tempname()
66  
-      let cmd = printf('(%s) 1>%s 2>%s', cmd,
67  
-            \ xolox#misc#escape#shell(tempout),
68  
-            \ xolox#misc#escape#shell(temperr))
  95
+      let cmd = printf('(%s) 1>%s 2>%s', cmd, xolox#misc#escape#shell(tempout), xolox#misc#escape#shell(temperr))
69 96
     endif
70 97
 
71 98
     " If A) we're on Windows, B) the vim-shell plug-in is installed and C) the
15  autoload/xolox/misc/timer.vim
... ...
@@ -1,7 +1,7 @@
1 1
 " Timing of long during operations.
2 2
 "
3 3
 " Author: Peter Odding <peter@peterodding.com>
4  
-" Last Change: May 19, 2013
  4
+" Last Change: May 20, 2013
5 5
 " URL: http://peterodding.com/code/vim/misc/
6 6
 
7 7
 if !exists('g:timer_enabled')
@@ -17,10 +17,7 @@ let s:has_reltime = has('reltime')
17 17
 function! xolox#misc#timer#start() " {{{1
18 18
   " Start a timer. This returns a list which can later be passed to
19 19
   " `xolox#misc#timer#stop()`.
20  
-  if g:timer_enabled || &verbose >= g:timer_verbosity
21  
-    return s:has_reltime ? reltime() : [localtime()]
22  
-  endif
23  
-  return []
  20
+  return s:has_reltime ? reltime() : [localtime()]
24 21
 endfunction
25 22
 
26 23
 function! xolox#misc#timer#stop(...) " {{{1
@@ -40,6 +37,14 @@ function! xolox#misc#timer#stop(...) " {{{1
40 37
   endif
41 38
 endfunction
42 39
 
  40
+function! xolox#misc#timer#force(...) " {{{1
  41
+  " Show a formatted message to the user. This function has the same argument
  42
+  " handling as Vim's [printf()] [printf] function with one difference: At the
  43
+  " point where you want the elapsed time to be embedded, you write `%s` and
  44
+  " you pass the list returned by `xolox#misc#timer#start()` as an argument.
  45
+  call call('xolox#misc#msg#info', map(copy(a:000), 's:convert_value(v:val)'))
  46
+endfunction
  47
+
43 48
 function! s:convert_value(value) " {{{1
44 49
   if type(a:value) != type([])
45 50
     return a:value

0 notes on commit 942f58a

Please sign in to comment.
Something went wrong with that request. Please try again.