Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Define version as variable, include version in messages

  • Loading branch information...
commit b92c6296ccabaca1fb24ca611042ec3bfe74a451 1 parent 35be685
Peter Odding authored August 27, 2011
36  autoload/xolox/luainspect.vim
... ...
@@ -1,9 +1,9 @@
1 1
 " Vim script.
2 2
 " Author: Peter Odding <peter@peterodding.com>
3  
-" Last Change: June 18, 2011
  3
+" Last Change: August 27, 2011
4 4
 " URL: http://peterodding.com/code/vim/lua-inspect/
5 5
 
6  
-let s:script = expand('<sfile>:p:~')
  6
+let g:xolox#luainspect#version = '0.4.11'
7 7
 
8 8
 function! xolox#luainspect#auto_enable() " {{{1
9 9
   if !&diff && !exists('b:luainspect_disabled')
@@ -73,9 +73,9 @@ function! xolox#luainspect#make_request(action) " {{{1
73 73
         let error_cmd = 'syntax match luaInspectSyntaxError /\%%>%il\%%<%il.*/ containedin=ALLBUT,lua*Comment*'
74 74
         execute printf(error_cmd, linenum - 1, (linenum2 ? linenum2 : line('$')) + 1)
75 75
       endif
76  
-      call xolox#misc#timer#stop("%s: Found a syntax error in %s in %s.", s:script, friendlyname, starttime)
  76
+      call xolox#misc#timer#stop("luainspect.vim %s: Found a syntax error in %s in %s.", g:xolox#luainspect#version, friendlyname, starttime)
77 77
       " But always let the user know that a syntax error exists.
78  
-      call xolox#misc#msg#warn("Syntax error around line %i in %s: %s", linenum, friendlyname, b:luainspect_syntax_error)
  78
+      call xolox#misc#msg#warn("luainspect.vim %s: Syntax error around line %i in %s: %s", g:xolox#luainspect#version, linenum, friendlyname, b:luainspect_syntax_error)
79 79
       return
80 80
     endif
81 81
     unlet! b:luainspect_syntax_error
@@ -83,31 +83,31 @@ function! xolox#luainspect#make_request(action) " {{{1
83 83
       call s:define_default_styles()
84 84
       call s:clear_previous_matches()
85 85
       call s:highlight_variables()
86  
-      call xolox#misc#timer#stop("%s: Highlighted variables in %s in %s.", s:script, friendlyname, starttime)
  86
+      call xolox#misc#timer#stop("luainspect.vim %s: Highlighted variables in %s in %s.", g:xolox#luainspect#version, friendlyname, starttime)
87 87
     elseif response == 'goto'
88 88
       if len(b:luainspect_output) < 3
89  
-        call xolox#misc#msg#warn("No variable under cursor!")
  89
+        call xolox#misc#msg#warn("luainspect.vim %s: No variable under cursor!", g:xolox#luainspect#version)
90 90
       else
91 91
         let linenum = b:luainspect_output[1] + 0
92 92
         let colnum = b:luainspect_output[2] + 1
93 93
         call setpos('.', [0, linenum, colnum, 0])
94  
-        call xolox#misc#timer#stop("%s: Jumped to definition in %s in %s.", s:script, friendlyname, starttime)
  94
+        call xolox#misc#timer#stop("luainspect.vim %s: Jumped to definition in %s in %s.", g:xolox#luainspect#version, friendlyname, starttime)
95 95
         if &verbose == 0
96 96
           " Clear previous "No variable under cursor!" message to avoid confusion.
97  
-          call xolox#misc#msg#info("")
  97
+          redraw | echo ""
98 98
         endif
99 99
       endif
100 100
     elseif response == 'tooltip'
101 101
       if len(b:luainspect_output) > 1
102  
-        call xolox#misc#timer#stop("%s: Rendered tool tip for %s in %s.", s:script, friendlyname, starttime)
  102
+        call xolox#misc#timer#stop("luainspect.vim %s: Rendered tool tip for %s in %s.", g:xolox#luainspect#version, friendlyname, starttime)
103 103
         return join(b:luainspect_output[1:-1], "\n")
104 104
       endif
105 105
     elseif response == 'rename'
106 106
       if len(b:luainspect_output) > 1
107  
-        call xolox#misc#timer#stop("%s: Prepared for rename in %s in %s.", s:script, friendlyname, starttime)
  107
+        call xolox#misc#timer#stop("luainspect.vim %s: Prepared for rename in %s in %s.", g:xolox#luainspect#version, friendlyname, starttime)
108 108
         call s:rename_variable()
109 109
       else
110  
-        call xolox#misc#msg#warn("No variable under cursor!")
  110
+        call xolox#misc#msg#warn("luainspect.vim %s: No variable under cursor!", g:xolox#luainspect#version)
111 111
       endif
112 112
     endif
113 113
   endif
@@ -139,8 +139,8 @@ function! s:parse_text(input, search_path) " {{{1
139 139
         " Ignore missing shell.vim plug-in.
140 140
         let b:luainspect_output = split(system(command, a:input), "\n")
141 141
         if v:shell_error
142  
-          let msg = "Failed to execute LuaInspect as external process! %s"
143  
-          throw printf(msg, strtrans(join(b:luainspect_output, "\n")))
  142
+          let msg = "luainspect.vim %s: Failed to execute LuaInspect as external process! %s"
  143
+          throw printf(msg, g:xolox#luainspect#version, strtrans(join(b:luainspect_output, "\n")))
144 144
         endif
145 145
       endtry
146 146
     else
@@ -258,8 +258,8 @@ function! s:rename_variable() " {{{1
258 258
   redraw
259 259
   " Prompt for new name.
260 260
   let oldname = expand('<cword>')
261  
-  let prompt = "Please enter the new name for %s: "
262  
-  let newname = input(printf(prompt, oldname), oldname)
  261
+  let prompt = "luainspect.vim %s: Please enter the new name for %s: "
  262
+  let newname = input(printf(prompt, g:xolox#luainspect#version, oldname), oldname)
263 263
   " Clear highlighting of occurrences.
264 264
   call map(highlights, 'matchdelete(v:val)')
265 265
   " Perform rename?
@@ -278,8 +278,8 @@ function! s:rename_variable() " {{{1
278 278
       call setline(linenum, prefix . newname . suffix)
279 279
       let num_renamed += 1
280 280
     endfor
281  
-    let msg = "Renamed %i occurrences of %s to %s"
282  
-    call xolox#misc#msg#info(msg, num_renamed, oldname, newname)
  281
+    let msg = "luainspect.vim %s: Renamed %i occurrences of %s to %s"
  282
+    call xolox#misc#msg#info(msg, g:xolox#luainspect#version, num_renamed, oldname, newname)
283 283
   endif
284 284
 endfunction
285 285
 
@@ -287,7 +287,7 @@ function! s:check_output(line, pattern) " {{{1
287 287
   if match(a:line, a:pattern) >= 0
288 288
     return 1
289 289
   else
290  
-    call xolox#misc#msg#warn("Invalid output from luainspect4vim.lua: '%s'", strtrans(a:line))
  290
+    call xolox#misc#msg#warn("luainspect.vim %s: Invalid output from luainspect4vim.lua: '%s'", g:xolox#luainspect#version, strtrans(a:line))
291 291
     return 0
292 292
   endif
293 293
 endfunction
3  plugin/luainspect.vim
... ...
@@ -1,8 +1,7 @@
1 1
 " Vim plug-in
2 2
 " Author: Peter Odding <peter@peterodding.com>
3  
-" Last Change: June 18, 2011
  3
+" Last Change: August 27, 2011
4 4
 " URL: http://peterodding.com/code/vim/lua-inspect/
5  
-" Version: 0.4.10
6 5
 
7 6
 " Support for automatic update using the GLVS plug-in.
8 7
 " GetLatestVimScripts: 3169 1 :AutoInstall: luainspect.zip

0 notes on commit b92c629

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