Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Enable highlightig on user defined events

  • Loading branch information...
commit d07a1ff10cbd78d5e16c28d234b5e37bc0de88ad 1 parent 67777a7
Peter Odding authored July 27, 2010

Showing 2 changed files with 20 additions and 9 deletions. Show diff stats Hide diff stats

  1. 14  README.md
  2. 15  luainspect.vim
14  README.md
Source Rendered
@@ -16,7 +16,7 @@ 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 the LuaInspect tool and then highlights all variables in the current buffer using one of the following highlighting groups:
  19
+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:
20 20
 
21 21
  * <span style="color: #600000">luaInspectGlobalDefined</span>
22 22
  * <span style="color: #FFF; background: #F00">luaInspectGlobalUndefined</span>
@@ -30,11 +30,17 @@ You shouldn't need to execute this command manually unless you've disabled autom
30 30
 
31 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).
32 32
 
33  
-### The `g:lua_inspect_automatic` option
  33
+### The `g:lua_inspect_events` option
34 34
 
35  
-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):
  35
+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):
36 36
 
37  
-    :let g:lua_inspect_automatic = 0
  37
+    :let g:lua_inspect_events = ''
  38
+
  39
+You can also add events, e.g.:
  40
+
  41
+    :let g:lua_inspect_events = 'CursorHold,CursorHoldI,InsertLeave'
  42
+
  43
+Note that this only works when the plug-in is loaded (or reloaded) *after* setting the `g:lua_inspect_events` option.
38 44
 
39 45
 ### The `g:lua_inspect_internal` option
40 46
 
15  luainspect.vim
@@ -6,9 +6,9 @@
6 6
 
7 7
 " Configuration defaults. {{{1
8 8
 
9  
-if !exists('g:lua_inspect_automatic')
10  
-  " Set this to false (0) to disable the automatic command.
11  
-  let g:lua_inspect_automatic = 1
  9
+if !exists('g:lua_inspect_events')
  10
+  " Change this to enable semantic highlighting on your preferred events.
  11
+  let g:lua_inspect_events = 'CursorHold,CursorHoldI,BufWritePost'
12 12
 endif
13 13
 
14 14
 if !exists('g:lua_inspect_internal')
@@ -24,13 +24,18 @@ endif
24 24
 command! LuaInspect call s:RunLuaInspect()
25 25
 
26 26
 augroup PluginLuaInspect
27  
-  autocmd! CursorHold,CursorHoldI * call s:AutoEnable()
  27
+  " Clear existing automatic commands.
  28
+  autocmd! 
  29
+  " Define the configured automatic commands.
  30
+  for s:event in split(g:lua_inspect_events, ',')
  31
+    execute 'autocmd' s:event '* call s:AutoEnable()'
  32
+  endfor
28 33
 augroup END
29 34
 
30 35
 " Script local functions. {{{1
31 36
 
32 37
 function! s:AutoEnable()
33  
-  if &filetype == 'lua' && g:lua_inspect_automatic
  38
+  if &filetype == 'lua'
34 39
     LuaInspect
35 40
   end
36 41
 endfunction

0 notes on commit d07a1ff

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