Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

README improvements, miscellaneous other changes

  • Loading branch information...
1 parent 95ad683 commit ec4e1c31facda80b316a5062fe71a4fe40e07f84 @xolox committed
Showing with 70 additions and 23 deletions.
  1. +41 −4
  2. +13 −13 luainspect.vim
  3. +16 −6 luainspect4vim.lua
@@ -4,14 +4,51 @@ The Vim plug-in `luainspect.vim` uses the [LuaInspect](
## Installation
-1. Download the latest [LuaInspect sources]( and unpack the contents of the `luainspectlib/` and `metalualib/` directories where Lua's `require()` function can find them.
+1. Unzip the most recent [ZIP archive]( file inside your Vim profile directory (usually this is `~/.vim` on UNIX and `%USERPROFILE%\vimfiles` on Windows) and move or symlink the file `luainspect4vim.lua` somewhere where Lua's `require()` function can find it.
-2. Save the Lua module [luainspect4vim.lua]( somewhere where Lua's `require()` function can find it.
+2. Download the latest [LuaInspect sources]( and unpack the contents of the `luainspectlib/` and `metalualib/` directories where Lua's `require()` function can find them.
-3. Save the Vim plug-in [luainspect.vim]( in the directory `$HOME/.vim/plugin` (on UNIX) or `%USERPROFILE%\vimfiles\plugin` (on Windows).
+3. Restart Vim and edit any Lua file. Within a few seconds semantic highlighting should be enabled automatically.
-4. Restart Vim and edit any Lua file. Within a few seconds semantic highlighting should be enabled automatically.
+## 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.
+### The `:LuaInspect` command
+You shouldn't need to execute this command manually unless you've disabled automatic highlighting using the `g:lua_inspect_automatic` option. When you execute the `:LuaInspect` command the plug-in runs LuaInspect and then highlights all variables in the current buffer using one of the following highlighting groups:
+ * `luaInspectGlobalDefined`
+ * `luaInspectGlobalUndefined`
+ * `luaInspectLocalUnused`
+ * `luaInspectLocalMutated`
+ * `luaInspectUpValue`
+ * `luaInspectParam`
+ * `luaInspectLocal`
+ * `luaInspectFieldDefined`
+ * `luaInspectFieldUndefined`
+### The `g:lua_inspect_automatic` option
+By default semantic highlighting is automatically enabled after a short timeout. If you don't want this you can add the following to your [vimrc script](
+ :let g:lua_inspect_automatic = 0
+### The `g:lua_inspect_internal` option
+The plug-in can use the Lua interface for Vim so it doesn't have to run LuaInspect as an external program (which can slow things down). This feature isn't enabled by default though, because the Lua interface for Vim doesn't include most of `io.*` and `os.*` from Lua's standard library, and this causes LuaInspect to flag all references to those modules as undefined global variables! If you want to enable use of the Lua interface for Vim despite this, you can add the following to your [vimrc script](
+ :let g:lua_inspect_internal = 1
## Limitations
Right now the highlighting styles used by `luainspect.vim` are the same as those used by the SciTE plug-in and they don't work well on dark backgrounds. As soon as I get around to picking some alternate colors I'll include those in the plug-in.
+## Contact
+If you have questions, bug reports, suggestions, etc. the author can be contacted at <>. The latest version is available at <> and <>. If you like this plug-in please vote for it on [](
+## License
+This software is licensed under the [MIT license](
+© 2010 Peter Odding &lt;<>&gt;.
26 luainspect.vim
@@ -2,7 +2,7 @@
" Author: Peter Odding <>
" Last Change: July 27, 2010
" URL:
-" Version: 0.1
+" Version: 0.1.2
" Configuration defaults. {{{1
@@ -64,25 +64,25 @@ endfunction
function! s:InitHighlighting()
" Clear existing highlighting.
- if hlexists('luaInspectDefinedGlobal') | syntax clear luaInspectDefinedGlobal | endif
- if hlexists('luaInspectUndefinedGlobal') | syntax clear luaInspectUndefinedGlobal | endif
- if hlexists('luaInspectUnusedLocal') | syntax clear luaInspectUnusedLocal | endif
- if hlexists('luaInspectMutatedLocal') | syntax clear luaInspectMutatedLocal | endif
+ if hlexists('luaInspectGlobalDefined') | syntax clear luaInspectGlobalDefined | endif
+ if hlexists('luaInspectGlobalUndefined') | syntax clear luaInspectGlobalUndefined | endif
+ if hlexists('luaInspectLocalUnused') | syntax clear luaInspectLocalUnused | endif
+ if hlexists('luaInspectLocalMutated') | syntax clear luaInspectLocalMutated | endif
if hlexists('luaInspectUpValue') | syntax clear luaInspectUpValue | endif
if hlexists('luaInspectParam') | syntax clear luaInspectParam | endif
if hlexists('luaInspectLocal') | syntax clear luaInspectLocal | endif
- if hlexists('luaInspectDefinedField') | syntax clear luaInspectDefinedField | endif
- if hlexists('luaInspectUndefinedField') | syntax clear luaInspectUndefinedField | endif
+ if hlexists('luaInspectFieldDefined') | syntax clear luaInspectFieldDefined | endif
+ if hlexists('luaInspectFieldUndefined') | syntax clear luaInspectFieldUndefined | endif
" Define default styles (copied from /luainspect/scite.lua for consistency).
- hi luaInspectDefinedGlobal guifg=#600000
- hi def link luaInspectUndefinedGlobal WarningMsg
- hi luaInspectUnusedLocal guifg=#ffffff guibg=#0000ff
- hi luaInspectMutatedLocal gui=italic guifg=#000080
+ hi luaInspectGlobalDefined guifg=#600000
+ hi def link luaInspectGlobalUndefined WarningMsg
+ hi luaInspectLocalUnused guifg=#ffffff guibg=#0000ff
+ hi luaInspectLocalMutated gui=italic guifg=#000080
hi luaInspectUpValue guifg=#0000ff
hi luaInspectParam guifg=#000040
hi luaInspectLocal guifg=#000080
- hi luaInspectDefinedField guifg=#600000
- hi luaInspectUndefinedField guifg=#c00000
+ hi luaInspectFieldDefined guifg=#600000
+ hi luaInspectFieldUndefined guifg=#c00000
" TODO Consider the &background?
22 luainspect4vim.lua
@@ -1,3 +1,13 @@
+ This module is part of the luainspect.vim plug-in for the Vim text editor.
+ Author: Peter Odding <>
+ Last Change: July 27, 2010
+ URL:
local function offset2lineinfo(text, offset)
-- TODO Cache intermediate results because they won't change within a single
-- call to the function returned from this module below.
@@ -37,15 +47,15 @@ return function(text)
for i, note in ipairs(LI.inspect(ast)) do
if note.type == 'global' then
if note.definedglobal then
- dumpvar('luaInspectDefinedGlobal', note[1], note[2])
+ dumpvar('luaInspectGlobalDefined', note[1], note[2])
- dumpvar('luaInspectUndefinedGlobal', note[1], note[2])
+ dumpvar('luaInspectGlobalUndefined', note[1], note[2])
elseif note.type == 'local' then
if not note.ast.localdefinition.isused then
- dumpvar('luaInspectUnusedLocal', note[1], note[2])
+ dumpvar('luaInspectLocalUnused', note[1], note[2])
elseif note.ast.localdefinition.isset then
- dumpvar('luaInspectMutatedLocal', note[1], note[2])
+ dumpvar('luaInspectLocalMutated', note[1], note[2])
elseif note.ast.localdefinition.functionlevel < note.ast.functionlevel then
dumpvar('luaInspectUpValue', note[1], note[2])
elseif note.ast.localdefinition.isparam then
@@ -55,9 +65,9 @@ return function(text)
elseif note.type == 'field' then
if note.definedglobal or note.ast.seevalue.value ~= nil then
- dumpvar('luaInspectDefinedField', note[1], note[2])
+ dumpvar('luaInspectFieldDefined', note[1], note[2])
- dumpvar('luaInspectUndefinedField', note[1], note[2])
+ dumpvar('luaInspectFieldUndefined', note[1], note[2])

0 comments on commit ec4e1c3

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