Skip to content

Commit

Permalink
Enable highlightig on user defined events
Browse files Browse the repository at this point in the history
  • Loading branch information
xolox committed Jul 27, 2010
1 parent 67777a7 commit d07a1ff
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
14 changes: 10 additions & 4 deletions README.md
Expand Up @@ -16,7 +16,7 @@ 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 the LuaInspect tool and then highlights all variables in the current buffer using one of the following highlighting groups:
You shouldn't need to execute this command manually unless you've disabled automatic highlighting using the `g:lua_inspect_events` 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>
Expand All @@ -30,11 +30,17 @@ You shouldn't need to execute this command manually unless you've disabled autom

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
### The `g:lua_inspect_events` 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](http://vimdoc.sourceforge.net/htmldoc/starting.html#vimrc):
By default semantic highlighting is automatically enabled after a short timeout and when you save a buffer. If you want to disable automatic highlighting altogether add the following to your [vimrc script](http://vimdoc.sourceforge.net/htmldoc/starting.html#vimrc):

:let g:lua_inspect_automatic = 0
:let g:lua_inspect_events = ''

You can also add events, e.g.:

:let g:lua_inspect_events = 'CursorHold,CursorHoldI,InsertLeave'

Note that this only works when the plug-in is loaded (or reloaded) *after* setting the `g:lua_inspect_events` option.

### The `g:lua_inspect_internal` option

Expand Down
15 changes: 10 additions & 5 deletions luainspect.vim
Expand Up @@ -6,9 +6,9 @@

" Configuration defaults. {{{1

if !exists('g:lua_inspect_automatic')
" Set this to false (0) to disable the automatic command.
let g:lua_inspect_automatic = 1
if !exists('g:lua_inspect_events')
" Change this to enable semantic highlighting on your preferred events.
let g:lua_inspect_events = 'CursorHold,CursorHoldI,BufWritePost'
endif

if !exists('g:lua_inspect_internal')
Expand All @@ -24,13 +24,18 @@ endif
command! LuaInspect call s:RunLuaInspect()

augroup PluginLuaInspect
autocmd! CursorHold,CursorHoldI * call s:AutoEnable()
" Clear existing automatic commands.
autocmd!
" Define the configured automatic commands.
for s:event in split(g:lua_inspect_events, ',')
execute 'autocmd' s:event '* call s:AutoEnable()'
endfor
augroup END

" Script local functions. {{{1

function! s:AutoEnable()
if &filetype == 'lua' && g:lua_inspect_automatic
if &filetype == 'lua'
LuaInspect
end
endfunction
Expand Down

0 comments on commit d07a1ff

Please sign in to comment.