Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

README improvements, miscellaneous other changes

  • Loading branch information...
commit ec4e1c31facda80b316a5062fe71a4fe40e07f84 1 parent 95ad683
Peter Odding authored July 27, 2010
45  README.md
Source Rendered
@@ -4,14 +4,51 @@ The Vim plug-in `luainspect.vim` uses the [LuaInspect](http://lua-users.org/wiki
4 4
 
5 5
 ## Installation
6 6
 
7  
-1. Download the latest [LuaInspect sources](http://github.com/davidm/lua-inspect/zipball/master) and unpack the contents of the `luainspectlib/` and `metalualib/` directories where Lua's `require()` function can find them.
  7
+1. 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) and move or symlink the file `luainspect4vim.lua` somewhere where Lua's `require()` function can find it.
8 8
 
9  
-2. Save the Lua module [luainspect4vim.lua](http://github.com/xolox/vim-lua-inspect/raw/master/luainspect4vim.lua) somewhere where Lua's `require()` function can find it.
  9
+2. Download the latest [LuaInspect sources](http://github.com/davidm/lua-inspect/zipball/master) and unpack the contents of the `luainspectlib/` and `metalualib/` directories where Lua's `require()` function can find them.
10 10
 
11  
-3. Save the Vim plug-in [luainspect.vim](http://github.com/xolox/vim-lua-inspect/raw/master/luainspect.vim) in the directory `$HOME/.vim/plugin` (on UNIX) or `%USERPROFILE%\vimfiles\plugin` (on Windows).
  11
+3. Restart Vim and edit any Lua file. Within a few seconds semantic highlighting should be enabled automatically.
12 12
 
13  
-4. Restart Vim and edit any Lua file. Within a few seconds semantic highlighting should be enabled automatically.
  13
+## Usage
  14
+
  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.
  16
+
  17
+### The `:LuaInspect` command
  18
+
  19
+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:
  20
+
  21
+ * `luaInspectGlobalDefined`
  22
+ * `luaInspectGlobalUndefined`
  23
+ * `luaInspectLocalUnused`
  24
+ * `luaInspectLocalMutated`
  25
+ * `luaInspectUpValue`
  26
+ * `luaInspectParam`
  27
+ * `luaInspectLocal`
  28
+ * `luaInspectFieldDefined`
  29
+ * `luaInspectFieldUndefined`
  30
+
  31
+### The `g:lua_inspect_automatic` option
  32
+
  33
+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](http://vimdoc.sourceforge.net/htmldoc/starting.html#vimrc):
  34
+
  35
+    :let g:lua_inspect_automatic = 0
  36
+
  37
+### The `g:lua_inspect_internal` option
  38
+
  39
+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](http://vimdoc.sourceforge.net/htmldoc/starting.html#vimrc):
  40
+
  41
+    :let g:lua_inspect_internal = 1
14 42
 
15 43
 ## Limitations
16 44
 
17 45
 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.
  46
+
  47
+## Contact
  48
+
  49
+If you have questions, bug reports, suggestions, etc. the author can be contacted at <peter@peterodding.com>. The latest version is available at <http://peterodding.com/code/vim/lua-inspect/> and <http://github.com/xolox/vim-lua-inspect>. If you like this plug-in please vote for it on [www.vim.org](http://www.vim.org/scripts/script.php?script_id=3169).
  50
+
  51
+## License
  52
+
  53
+This software is licensed under the [MIT license](http://en.wikipedia.org/wiki/MIT_License).  
  54
+© 2010 Peter Odding &lt;<peter@peterodding.com>&gt;.
26  luainspect.vim
@@ -2,7 +2,7 @@
2 2
 " Author: Peter Odding <peter@peterodding.com>
3 3
 " Last Change: July 27, 2010
4 4
 " URL: http://peterodding.com/code/vim/lua-inspect/
5  
-" Version: 0.1
  5
+" Version: 0.1.2
6 6
 
7 7
 " Configuration defaults. {{{1
8 8
 
@@ -64,25 +64,25 @@ endfunction
64 64
 
65 65
 function! s:InitHighlighting()
66 66
   " Clear existing highlighting.
67  
-  if hlexists('luaInspectDefinedGlobal') | syntax clear luaInspectDefinedGlobal | endif
68  
-  if hlexists('luaInspectUndefinedGlobal') | syntax clear luaInspectUndefinedGlobal | endif
69  
-  if hlexists('luaInspectUnusedLocal') | syntax clear luaInspectUnusedLocal | endif
70  
-  if hlexists('luaInspectMutatedLocal') | syntax clear luaInspectMutatedLocal | endif
  67
+  if hlexists('luaInspectGlobalDefined') | syntax clear luaInspectGlobalDefined | endif
  68
+  if hlexists('luaInspectGlobalUndefined') | syntax clear luaInspectGlobalUndefined | endif
  69
+  if hlexists('luaInspectLocalUnused') | syntax clear luaInspectLocalUnused | endif
  70
+  if hlexists('luaInspectLocalMutated') | syntax clear luaInspectLocalMutated | endif
71 71
   if hlexists('luaInspectUpValue') | syntax clear luaInspectUpValue | endif
72 72
   if hlexists('luaInspectParam') | syntax clear luaInspectParam | endif
73 73
   if hlexists('luaInspectLocal') | syntax clear luaInspectLocal | endif
74  
-  if hlexists('luaInspectDefinedField') | syntax clear luaInspectDefinedField | endif
75  
-  if hlexists('luaInspectUndefinedField') | syntax clear luaInspectUndefinedField | endif
  74
+  if hlexists('luaInspectFieldDefined') | syntax clear luaInspectFieldDefined | endif
  75
+  if hlexists('luaInspectFieldUndefined') | syntax clear luaInspectFieldUndefined | endif
76 76
   " Define default styles (copied from /luainspect/scite.lua for consistency).
77  
-  hi luaInspectDefinedGlobal guifg=#600000
78  
-  hi def link luaInspectUndefinedGlobal WarningMsg
79  
-  hi luaInspectUnusedLocal guifg=#ffffff guibg=#0000ff
80  
-  hi luaInspectMutatedLocal gui=italic guifg=#000080
  77
+  hi luaInspectGlobalDefined guifg=#600000
  78
+  hi def link luaInspectGlobalUndefined WarningMsg
  79
+  hi luaInspectLocalUnused guifg=#ffffff guibg=#0000ff
  80
+  hi luaInspectLocalMutated gui=italic guifg=#000080
81 81
   hi luaInspectUpValue guifg=#0000ff
82 82
   hi luaInspectParam guifg=#000040
83 83
   hi luaInspectLocal guifg=#000080
84  
-  hi luaInspectDefinedField guifg=#600000
85  
-  hi luaInspectUndefinedField guifg=#c00000
  84
+  hi luaInspectFieldDefined guifg=#600000
  85
+  hi luaInspectFieldUndefined guifg=#c00000
86 86
   " TODO Consider the &background?
87 87
 endfunction
88 88
 
22  luainspect4vim.lua
... ...
@@ -1,3 +1,13 @@
  1
+--[[
  2
+
  3
+ This module is part of the luainspect.vim plug-in for the Vim text editor.
  4
+
  5
+ Author: Peter Odding <peter@peterodding.com>
  6
+ Last Change: July 27, 2010
  7
+ URL: http://peterodding.com/code/vim/lua-inspect/
  8
+
  9
+--]]
  10
+
1 11
 local function offset2lineinfo(text, offset)
2 12
   -- TODO Cache intermediate results because they won't change within a single
3 13
   --      call to the function returned from this module below.
@@ -37,15 +47,15 @@ return function(text)
37 47
       for i, note in ipairs(LI.inspect(ast)) do
38 48
         if note.type == 'global' then
39 49
           if note.definedglobal then
40  
-            dumpvar('luaInspectDefinedGlobal', note[1], note[2])
  50
+            dumpvar('luaInspectGlobalDefined', note[1], note[2])
41 51
           else
42  
-            dumpvar('luaInspectUndefinedGlobal', note[1], note[2])
  52
+            dumpvar('luaInspectGlobalUndefined', note[1], note[2])
43 53
           end
44 54
         elseif note.type == 'local' then
45 55
           if not note.ast.localdefinition.isused then
46  
-            dumpvar('luaInspectUnusedLocal', note[1], note[2])
  56
+            dumpvar('luaInspectLocalUnused', note[1], note[2])
47 57
           elseif note.ast.localdefinition.isset then
48  
-            dumpvar('luaInspectMutatedLocal', note[1], note[2])
  58
+            dumpvar('luaInspectLocalMutated', note[1], note[2])
49 59
           elseif note.ast.localdefinition.functionlevel  < note.ast.functionlevel then
50 60
             dumpvar('luaInspectUpValue', note[1], note[2])
51 61
           elseif note.ast.localdefinition.isparam then
@@ -55,9 +65,9 @@ return function(text)
55 65
           end
56 66
         elseif note.type == 'field' then
57 67
           if note.definedglobal or note.ast.seevalue.value ~= nil then
58  
-            dumpvar('luaInspectDefinedField', note[1], note[2])
  68
+            dumpvar('luaInspectFieldDefined', note[1], note[2])
59 69
           else
60  
-            dumpvar('luaInspectUndefinedField', note[1], note[2])
  70
+            dumpvar('luaInspectFieldUndefined', note[1], note[2])
61 71
           end
62 72
         end
63 73
       end

0 notes on commit ec4e1c3

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