Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Use real buffer names instead of `noname.lua'

  • Loading branch information...
commit 2e93bdd4f3de8a39fc22a6f2d29021a5873d057b 1 parent 2a33bcb
Peter Odding authored
16  autoload.vim
@@ -36,6 +36,7 @@ endfunction
36 36
 
37 37
 function! luainspect#make_request(action) " {{{1
38 38
   let starttime = xolox#timer#start()
  39
+  let bufname = fnamemodify(bufname(a:action != 'tooltip' ? '%' : v:beval_bufnr), ':p')
39 40
   if a:action == 'tooltip'
40 41
     let lines = getbufline(v:beval_bufnr, 1, "$")
41 42
     call insert(lines, v:beval_col)
@@ -45,11 +46,12 @@ function! luainspect#make_request(action) " {{{1
45 46
     call insert(lines, col('.'))
46 47
     call insert(lines, line('.'))
47 48
   endif
  49
+  call insert(lines, bufname)
48 50
   call insert(lines, a:action)
49 51
   call s:parse_text(join(lines, "\n"), s:prepare_search_path())
50 52
   if !empty(b:luainspect_output)
51 53
     let response = b:luainspect_output[0]
52  
-    let bufname = fnamemodify(bufname(a:action != 'tooltip' ? '%' : v:beval_bufnr), ':p:~')
  54
+    let friendlyname = fnamemodify(bufname, ':~')
53 55
     if response == 'syntax_error' && len(b:luainspect_output) >= 4
54 56
       " Never perform syntax error highlighting in non-Lua buffers!
55 57
       let linenum = b:luainspect_output[1] + 0
@@ -60,9 +62,9 @@ function! luainspect#make_request(action) " {{{1
60 62
         let error_cmd = 'syntax match luaInspectSyntaxError /\%%>%il\%%<%il.*/ containedin=ALLBUT,lua*Comment*'
61 63
         execute printf(error_cmd, linenum - 1, (linenum2 ? linenum2 : line('$')) + 1)
62 64
       endif
63  
-      call xolox#timer#stop("%s: Found a syntax error in %s in %s.", s:script, bufname, starttime)
  65
+      call xolox#timer#stop("%s: Found a syntax error in %s in %s.", s:script, friendlyname, starttime)
64 66
       " But always let the user know that a syntax error exists.
65  
-      call xolox#warning("Syntax error around line %i in %s: %s", linenum, bufname, b:luainspect_syntax_error)
  67
+      call xolox#warning("Syntax error around line %i in %s: %s", linenum, friendlyname, b:luainspect_syntax_error)
66 68
       return
67 69
     endif
68 70
     unlet! b:luainspect_syntax_error
@@ -70,7 +72,7 @@ function! luainspect#make_request(action) " {{{1
70 72
       call s:define_default_styles()
71 73
       call s:clear_previous_matches()
72 74
       call s:highlight_variables()
73  
-      call xolox#timer#stop("%s: Highlighted variables in %s in %s.", s:script, bufname, starttime)
  75
+      call xolox#timer#stop("%s: Highlighted variables in %s in %s.", s:script, friendlyname, starttime)
74 76
     elseif response == 'goto'
75 77
       if len(b:luainspect_output) < 3
76 78
         call xolox#warning("No variable under cursor!")
@@ -78,7 +80,7 @@ function! luainspect#make_request(action) " {{{1
78 80
         let linenum = b:luainspect_output[1] + 0
79 81
         let colnum = b:luainspect_output[2] + 0
80 82
         call setpos('.', [0, linenum, colnum, 0])
81  
-        call xolox#timer#stop("%s: Jumped to definition in %s in %s.", s:script, bufname, starttime)
  83
+        call xolox#timer#stop("%s: Jumped to definition in %s in %s.", s:script, friendlyname, starttime)
82 84
         if &verbose == 0
83 85
           " Clear previous "No variable under cursor!" message to avoid confusion.
84 86
           call xolox#message("")
@@ -86,12 +88,12 @@ function! luainspect#make_request(action) " {{{1
86 88
       endif
87 89
     elseif response == 'tooltip'
88 90
       if len(b:luainspect_output) > 1
89  
-        call xolox#timer#stop("%s: Rendered tool tip for %s in %s.", s:script, bufname, starttime)
  91
+        call xolox#timer#stop("%s: Rendered tool tip for %s in %s.", s:script, friendlyname, starttime)
90 92
         return join(b:luainspect_output[1:-1], "\n")
91 93
       endif
92 94
     elseif response == 'rename'
93 95
       if len(b:luainspect_output) > 1
94  
-        call xolox#timer#stop("%s: Prepared for rename in %s in %s.", s:script, bufname, starttime)
  96
+        call xolox#timer#stop("%s: Prepared for rename in %s in %s.", s:script, friendlyname, starttime)
95 97
         call s:rename_variable()
96 98
       else
97 99
         call xolox#warning("No variable under cursor!")
6  luainspect4vim.lua
@@ -3,7 +3,7 @@
3 3
  This module is part of the luainspect.vim plug-in for the Vim text editor.
4 4
 
5 5
  Author: Peter Odding <peter@peterodding.com>
6  
- Last Change: August 12, 2010
  6
+ Last Change: August 15, 2010
7 7
  URL: http://peterodding.com/code/vim/lua-inspect/
8 8
  License: MIT
9 9
 
@@ -253,7 +253,7 @@ end
253 253
 -- }}}
254 254
 
255 255
 return function(src)
256  
-  local action, line, column, src = src:match '^(%S+)\n(%d+)\n(%d+)\n(.*)$'
  256
+  local action, file, line, column, src = src:match '^(%S+)\n([^\n]+)\n(%d+)\n(%d+)\n(.*)$'
257 257
   line = tonumber(line)
258 258
   column = tonumber(column)
259 259
   src = LA.remove_shebang(src)
@@ -269,7 +269,7 @@ return function(src)
269 269
     return
270 270
   end
271 271
   -- Now parse the source code using metalua to build an abstract syntax tree.
272  
-  local ast; ast, err, linenum, colnum, linenum2 = LA.ast_from_string(src, "noname.lua")
  272
+  local ast = LA.ast_from_string(src, file)
273 273
   if not ast then return end
274 274
   -- Create a list of tokens from the AST and decorate it using luainspect.
275 275
   local tokenlist = LA.ast_to_tokenlist(ast, src)

0 notes on commit 2e93bdd

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