Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Don't show command prompts on Windows

  • Loading branch information...
commit 2689c2d1896d47c6aa3fa2d919d06d353cf0c17f 1 parent 43307cb
Peter Odding authored August 10, 2010

Showing 2 changed files with 16 additions and 3 deletions. Show diff stats Hide diff stats

  1. 2  README.md
  2. 17  luainspect.vim
2  README.md
Source Rendered
@@ -8,6 +8,8 @@ The Vim plug-in `luainspect.vim` uses the [LuaInspect](http://lua-users.org/wiki
8 8
 
9 9
 Unzip the most recent [ZIP archive](http://peterodding.com/code/vim/downloads/lua-inspect) file inside your Vim profile directory (usually this is `~/.vim` on UNIX and `%USERPROFILE%\vimfiles` on Windows), restart Vim and execute the command `:helptags ~/.vim/doc` (use `:helptags ~\vimfiles\doc` instead on Windows). Now try it out: Edit a Lua file and within a few seconds semantic highlighting should be enabled automatically!
10 10
 
  11
+Note that on Windows a command prompt window pops up whenever LuaInspect is run as an external process. If this bothers you then you can install my [shell.vim](http://peterodding.com/code/vim/shell/) plug-in which includes a [DLL](http://en.wikipedia.org/wiki/Dynamic-link_library) that works around this issue. Once you've installed both plug-ins it should work out of the box!
  12
+
11 13
 ## Usage
12 14
 
13 15
 When you open any Lua file the semantic highlighting should be enabled automatically within a few seconds, so you don't have to configure anything if you're happy with the defaults.
17  luainspect.vim
@@ -111,9 +111,19 @@ function! s:parse_text(input, search_path) " {{{2
111 111
   if !(exists('b:luainspect_input') && b:luainspect_input == a:input)
112 112
     if !(has('lua') && g:lua_inspect_internal)
113 113
       let template = 'lua -e "%s; require ''luainspect4vim'' (io.read ''*a'')"'
114  
-      let b:luainspect_output = system(printf(template, a:search_path), a:input)
  114
+      let command = printf(template, a:search_path)
  115
+      try
  116
+        let b:luainspect_output = xolox#shell#execute(command, 1, a:input)
  117
+      catch /^Vim\%((\a\+)\)\=:E117/
  118
+        " Ignore missing shell.vim plug-in.
  119
+        let b:luainspect_output = split(system(command, a:input), "\n")
  120
+        if v:shell_error
  121
+          let msg = "Failed to execute lua-inspect as external process! %s"
  122
+          throw printf(msg, strtrans(join(b:luainspect_output, "\n")))
  123
+        endif
  124
+      endtry
115 125
     else
116  
-      redir => b:luainspect_output
  126
+      redir => output
117 127
       silent lua << EOF
118 128
       if io == nil then
119 129
         -- The Lua interface for Vim previously didn't include io.*!
@@ -122,6 +132,7 @@ function! s:parse_text(input, search_path) " {{{2
122 132
       require 'luainspect4vim' (vim.eval 'a:input')
123 133
 EOF
124 134
       redir END
  135
+      let b:luainspect_output = split(output, "\n")
125 136
     endif
126 137
     " Remember the text that was just parsed.
127 138
     let b:luainspect_input = a:input
@@ -158,7 +169,7 @@ endfunction
158 169
 
159 170
 function! s:highlight_variables() " {{{2
160 171
   let did_warning = 0
161  
-  for line in split(b:luainspect_output, "\n")
  172
+  for line in b:luainspect_output
162 173
     if match(line, '^\w\+\(\s\+\d\+\)\{3}$') == -1
163 174
       if !did_warning
164 175
         try

0 notes on commit 2689c2d

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