Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Don't show command prompts on Windows

  • Loading branch information...
commit 2689c2d1896d47c6aa3fa2d919d06d353cf0c17f 1 parent 43307cb
@xolox authored
Showing with 16 additions and 3 deletions.
  1. +2 −0  README.md
  2. +14 −3 luainspect.vim
View
2  README.md
@@ -8,6 +8,8 @@ The Vim plug-in `luainspect.vim` uses the [LuaInspect](http://lua-users.org/wiki
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!
+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!
+
## 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.
View
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'' (io.read ''*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
else
- 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')
EOF
redir END
+ let b:luainspect_output = split(output, "\n")
endif
" 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
try
Please sign in to comment.
Something went wrong with that request. Please try again.