Skip to content
Browse files

Don't show command prompts on Windows

  • Loading branch information...
1 parent 43307cb commit 2689c2d1896d47c6aa3fa2d919d06d353cf0c17f @xolox committed
Showing with 16 additions and 3 deletions.
  1. +2 −0
  2. +14 −3 luainspect.vim
@@ -8,6 +8,8 @@ The Vim plug-in `luainspect.vim` uses the [LuaInspect](
Unzip the most recent [ZIP archive]( 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!
+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]( plug-in which includes a [DLL]( that works around this issue. Once you've installed both plug-ins it should work out of the box!
## Usage
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
if !(exists('b:luainspect_input') && b:luainspect_input == a:input)
if !(has('lua') && g:lua_inspect_internal)
let template = 'lua -e "%s; require ''luainspect4vim'' ( ''*a'')"'
- let b:luainspect_output = system(printf(template, a:search_path), a:input)
+ let command = printf(template, a:search_path)
+ try
+ let b:luainspect_output = xolox#shell#execute(command, 1, a:input)
+ catch /^Vim\%((\a\+)\)\=:E117/
+ " Ignore missing shell.vim plug-in.
+ let b:luainspect_output = split(system(command, a:input), "\n")
+ if v:shell_error
+ let msg = "Failed to execute lua-inspect as external process! %s"
+ throw printf(msg, strtrans(join(b:luainspect_output, "\n")))
+ endif
+ endtry
- redir => b:luainspect_output
+ redir => output
silent lua << EOF
if io == nil then
-- The Lua interface for Vim previously didn't include io.*!
@@ -122,6 +132,7 @@ function! s:parse_text(input, search_path) " {{{2
require 'luainspect4vim' (vim.eval 'a:input')
redir END
+ let b:luainspect_output = split(output, "\n")
" Remember the text that was just parsed.
let b:luainspect_input = a:input
@@ -158,7 +169,7 @@ endfunction
function! s:highlight_variables() " {{{2
let did_warning = 0
- for line in split(b:luainspect_output, "\n")
+ for line in b:luainspect_output
if match(line, '^\w\+\(\s\+\d\+\)\{3}$') == -1
if !did_warning

0 comments on commit 2689c2d

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