Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

README updates

 * Enable users to define styles which the plug-in won't override.

 * Preview default styles in README.md (I'm pretty sure GitHub will
   strip the <span> tags but on my homepage they are rendered).
  • Loading branch information...
commit 67777a75f4b9f4896d5818b57611d34c82a0187c 1 parent cfd4250
Peter Odding authored July 27, 2010

Showing 2 changed files with 42 additions and 24 deletions. Show diff stats Hide diff stats

  1. 24  README.md
  2. 42  luainspect.vim
24  README.md
Source Rendered
@@ -16,17 +16,19 @@ When you open any Lua file the semantic highlighting should be enabled automatic
16 16
 
17 17
 ### The `:LuaInspect` command
18 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`
  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 the LuaInspect tool and then highlights all variables in the current buffer using one of the following highlighting groups:
  20
+
  21
+ * <span style="color: #600000">luaInspectGlobalDefined</span>
  22
+ * <span style="color: #FFF; background: #F00">luaInspectGlobalUndefined</span>
  23
+ * <span style="color: #FFF; background: #00F">luaInspectLocalUnused</span>
  24
+ * <span style="color: #000080; font-style: italic">luaInspectLocalMutated</span>
  25
+ * <span style="color: #00F">luaInspectUpValue</span>
  26
+ * <span style="color: #000040">luaInspectParam</span>
  27
+ * <span style="color: #000080">luaInspectLocal</span>
  28
+ * <span style="color: #600000">luaInspectFieldDefined</span>
  29
+ * <span style="color: #C00000">luaInspectFieldUndefined</span>
  30
+
  31
+If you don't like one or more of the default styles the Vim documentation [describes how to change them](http://vimdoc.sourceforge.net/htmldoc/syntax.html#:hi-default).
30 32
 
31 33
 ### The `g:lua_inspect_automatic` option
32 34
 
42  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.2
  5
+" Version: 0.1.3
6 6
 
7 7
 " Configuration defaults. {{{1
8 8
 
@@ -53,7 +53,8 @@ EOF
53 53
     let listing = system("lua -e 'require\"luainspect4vim\" (io.read \"*a\")'", l:text)
54 54
   endif
55 55
   " Clear previously created highlighting.
56  
-  call s:InitHighlighting()
  56
+  call s:LoadDefaultStyles()
  57
+  call s:ClearPreviousMatches()
57 58
   " Highlight variables in buffer based on positions.
58 59
   for fields in split(listing, "\n")
59 60
     let [type, lnum, start, end] = split(fields)
@@ -62,7 +63,7 @@ EOF
62 63
   endfor
63 64
 endfunction
64 65
 
65  
-function! s:InitHighlighting()
  66
+function! s:ClearPreviousMatches()
66 67
   " Clear existing highlighting.
67 68
   if hlexists('luaInspectGlobalDefined') | syntax clear luaInspectGlobalDefined | endif
68 69
   if hlexists('luaInspectGlobalUndefined') | syntax clear luaInspectGlobalUndefined | endif
@@ -73,17 +74,32 @@ function! s:InitHighlighting()
73 74
   if hlexists('luaInspectLocal') | syntax clear luaInspectLocal | endif
74 75
   if hlexists('luaInspectFieldDefined') | syntax clear luaInspectFieldDefined | endif
75 76
   if hlexists('luaInspectFieldUndefined') | syntax clear luaInspectFieldUndefined | endif
76  
-  " Define default styles (copied from /luainspect/scite.lua for consistency).
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  
-  hi luaInspectUpValue guifg=#0000ff
82  
-  hi luaInspectParam guifg=#000040
83  
-  hi luaInspectLocal guifg=#000080
84  
-  hi luaInspectFieldDefined guifg=#600000
85  
-  hi luaInspectFieldUndefined guifg=#c00000
  77
+endfunction
  78
+
  79
+function! s:LoadDefaultStyles()
  80
+  " Always define the default highlighting styles
  81
+  " (copied from /luainspect/scite.lua for consistency).
86 82
   " TODO Consider the &background?
  83
+  highlight luaInspectDefGlobalDefined guifg=#600000
  84
+  highlight luaInspectDefLocalUnused guifg=#ffffff guibg=#0000ff
  85
+  highlight luaInspectDefLocalMutated gui=italic guifg=#000080
  86
+  highlight luaInspectDefUpValue guifg=#0000ff
  87
+  highlight luaInspectDefParam guifg=#000040
  88
+  highlight luaInspectDefLocal guifg=#000080
  89
+  highlight luaInspectDefFieldDefined guifg=#600000
  90
+  highlight luaInspectDefFieldUndefined guifg=#c00000
  91
+  " Don't link the actual highlighting styles to the defaults if the user
  92
+  " has already defined or linked the highlighting group. This enables color
  93
+  " schemes and vimrc scripts to override the styles (see :help :hi-default).
  94
+  highlight def link luaInspectGlobalDefined luaInspectDefGlobalDefined
  95
+  highlight def link luaInspectGlobalUndefined Error
  96
+  highlight def link luaInspectLocalUnused luaInspectDefLocalUnused
  97
+  highlight def link luaInspectLocalMutated luaInspectDefLocalMutated
  98
+  highlight def link luaInspectUpValue luaInspectDefUpValue
  99
+  highlight def link luaInspectParam luaInspectDefParam
  100
+  highlight def link luaInspectLocal luaInspectDefLocal
  101
+  highlight def link luaInspectFieldDefined luaInspectDefFieldDefined
  102
+  highlight def link luaInspectFieldUndefined luaInspectDefFieldUndefined
87 103
 endfunction
88 104
 
89 105
 " vim: ts=2 sw=2 et

0 notes on commit 67777a7

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