Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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
@xolox authored
Showing with 42 additions and 24 deletions.
  1. +13 −11 README.md
  2. +29 −13 luainspect.vim
View
24 README.md
@@ -16,17 +16,19 @@ When you open any Lua file the semantic highlighting should be enabled automatic
### 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`
+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:
+
+ * <span style="color: #600000">luaInspectGlobalDefined</span>
+ * <span style="color: #FFF; background: #F00">luaInspectGlobalUndefined</span>
+ * <span style="color: #FFF; background: #00F">luaInspectLocalUnused</span>
+ * <span style="color: #000080; font-style: italic">luaInspectLocalMutated</span>
+ * <span style="color: #00F">luaInspectUpValue</span>
+ * <span style="color: #000040">luaInspectParam</span>
+ * <span style="color: #000080">luaInspectLocal</span>
+ * <span style="color: #600000">luaInspectFieldDefined</span>
+ * <span style="color: #C00000">luaInspectFieldUndefined</span>
+
+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).
### The `g:lua_inspect_automatic` option
View
42 luainspect.vim
@@ -2,7 +2,7 @@
" Author: Peter Odding <peter@peterodding.com>
" Last Change: July 27, 2010
" URL: http://peterodding.com/code/vim/lua-inspect/
-" Version: 0.1.2
+" Version: 0.1.3
" Configuration defaults. {{{1
@@ -53,7 +53,8 @@ EOF
let listing = system("lua -e 'require\"luainspect4vim\" (io.read \"*a\")'", l:text)
endif
" Clear previously created highlighting.
- call s:InitHighlighting()
+ call s:LoadDefaultStyles()
+ call s:ClearPreviousMatches()
" Highlight variables in buffer based on positions.
for fields in split(listing, "\n")
let [type, lnum, start, end] = split(fields)
@@ -62,7 +63,7 @@ EOF
endfor
endfunction
-function! s:InitHighlighting()
+function! s:ClearPreviousMatches()
" Clear existing highlighting.
if hlexists('luaInspectGlobalDefined') | syntax clear luaInspectGlobalDefined | endif
if hlexists('luaInspectGlobalUndefined') | syntax clear luaInspectGlobalUndefined | endif
@@ -73,17 +74,32 @@ function! s:InitHighlighting()
if hlexists('luaInspectLocal') | syntax clear luaInspectLocal | 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 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 luaInspectFieldDefined guifg=#600000
- hi luaInspectFieldUndefined guifg=#c00000
+endfunction
+
+function! s:LoadDefaultStyles()
+ " Always define the default highlighting styles
+ " (copied from /luainspect/scite.lua for consistency).
" TODO Consider the &background?
+ highlight luaInspectDefGlobalDefined guifg=#600000
+ highlight luaInspectDefLocalUnused guifg=#ffffff guibg=#0000ff
+ highlight luaInspectDefLocalMutated gui=italic guifg=#000080
+ highlight luaInspectDefUpValue guifg=#0000ff
+ highlight luaInspectDefParam guifg=#000040
+ highlight luaInspectDefLocal guifg=#000080
+ highlight luaInspectDefFieldDefined guifg=#600000
+ highlight luaInspectDefFieldUndefined guifg=#c00000
+ " Don't link the actual highlighting styles to the defaults if the user
+ " has already defined or linked the highlighting group. This enables color
+ " schemes and vimrc scripts to override the styles (see :help :hi-default).
+ highlight def link luaInspectGlobalDefined luaInspectDefGlobalDefined
+ highlight def link luaInspectGlobalUndefined Error
+ highlight def link luaInspectLocalUnused luaInspectDefLocalUnused
+ highlight def link luaInspectLocalMutated luaInspectDefLocalMutated
+ highlight def link luaInspectUpValue luaInspectDefUpValue
+ highlight def link luaInspectParam luaInspectDefParam
+ highlight def link luaInspectLocal luaInspectDefLocal
+ highlight def link luaInspectFieldDefined luaInspectDefFieldDefined
+ highlight def link luaInspectFieldUndefined luaInspectDefFieldUndefined
endfunction
" vim: ts=2 sw=2 et
Please sign in to comment.
Something went wrong with that request. Please try again.