Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Now works on Windows and disables easytags.vim

 * When I tested luainspect.vim on Windows for the first time and found
   that it didn't work (using Vim 7.2 without if-lua) I realized Windows
   programs generally don't like single quoted arguments so I inverted
   all quotes and now it works :-D

 * My easytags.vim plug-in also performs dynamic highlighting (which is
   why it wasn't difficult for me to write the first prototype of
   luainspect.vim) and the two types of highlighting conflict with each
   other. Because I believe luainspect.vim to be of more value then the
   minimal highlighting done by easytags.vim I've disabled that.

 * Removed the workaround for the editor.LineCount reference in ast.lua
   since it's already fixed in luainspect HEAD. Thanks David!
  • Loading branch information...
commit ce2b578242ccf3d4eef658accc7e4711f34fbbbc 1 parent 3968548
Peter Odding authored August 10, 2010
16  luainspect.vim
... ...
@@ -1,6 +1,6 @@
1 1
 " Vim plug-in
2 2
 " Author: Peter Odding <peter@peterodding.com>
3  
-" Last Change: August 8, 2010
  3
+" Last Change: August 10, 2010
4 4
 " URL: http://peterodding.com/code/vim/lua-inspect/
5 5
 " Version: 0.2.1
6 6
 " License: MIT
@@ -46,19 +46,19 @@ command! -bar -bang LuaInspect call s:RunLuaInspect(<q-bang> == '!')
46 46
 
47 47
 augroup PluginLuaInspect
48 48
   " Clear existing automatic commands.
49  
-  autocmd! 
  49
+  autocmd!
  50
+  " Disable easytags.vim because it doesn't play nice with luainspect.vim!
  51
+  autocmd BufReadPost * if s:IsEnabled() | let b:easytags_nohl = 1 | endif
50 52
   " Define the configured automatic commands.
51 53
   for s:event in split(g:lua_inspect_events, ',')
52  
-    execute 'autocmd' s:event '* call s:AutoEnable()'
  54
+    execute 'autocmd' s:event '* if s:IsEnabled() | LuaInspect | endif'
53 55
   endfor
54 56
 augroup END
55 57
 
56 58
 " Script local functions. {{{1
57 59
 
58  
-function! s:AutoEnable() " {{{2
59  
-  if &ft == 'lua' && !&diff && !exists('b:luainspect_disabled')
60  
-    LuaInspect
61  
-  end
  60
+function! s:IsEnabled()
  61
+  return &ft == 'lua' && !&diff && !exists('b:luainspect_disabled')
62 62
 endfunction
63 63
 
64 64
 function! s:RunLuaInspect(disable) " {{{2
@@ -78,7 +78,7 @@ function! s:RunLuaInspect(disable) " {{{2
78 78
   if !(exists('b:luainspect_input') && b:luainspect_input == l:input)
79 79
     if !(has('lua') && g:lua_inspect_internal)
80 80
       " Run LuaInspect as an external program.
81  
-      let b:luainspect_output = system("lua -e 'require\"luainspect4vim\" (io.read \"*a\")'", l:input)
  81
+      let b:luainspect_output = system('lua -e "require ''luainspect4vim'' (io.read ''*a'')"', l:input)
82 82
     else
83 83
       " Run LuaInspect using the Lua interface for Vim.
84 84
       redir => b:luainspect_output
8  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 7, 2010
  6
+ Last Change: August 10, 2010
7 7
  URL: http://peterodding.com/code/vim/lua-inspect/
8 8
  License: MIT
9 9
 
@@ -46,13 +46,7 @@ return function(src)
46 46
   src = LA.remove_shebang(src)
47 47
   local f, err, linenum, colnum, linenum2 = LA.loadstring(src)
48 48
   if not f then return end -- TODO Highlight syntax errors like spelling errors
49  
-  -- FIXME ast_from_string() references editor.LineCount
50  
-  local numlines = 1
51  
-  for _ in src:gmatch '\n' do numlines = numlines + 1 end
52  
-  local editor_save = _G.editor
53  
-  _G.editor = { lineCount = numlines }
54 49
   local ast; ast, err, linenum, colnum, linenum2 = LA.ast_from_string(src, "noname.lua")
55  
-  _G.editor = editor_save
56 50
   if not ast then return end
57 51
   local tokenlist = LA.ast_to_tokenlist(ast, src)
58 52
   LI.inspect(ast, tokenlist)

0 notes on commit ce2b578

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