Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Support disabling plug-in for specific buffers
  • Loading branch information
xolox committed Aug 7, 2010
1 parent 7bec1f4 commit 3e59671
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
8 changes: 8 additions & 0 deletions README.md
Expand Up @@ -31,6 +31,14 @@ You don't need to use this command unless you've disabled automatic highlighting

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).

If you want to disable the semantic highlighting in a specific Vim buffer execute `:LuaInspect!` in that buffer. When you want to reenable the highlighting execute `:LuaInspect` again, but now without the [bang](http://vimdoc.sourceforge.net/htmldoc/map.html#:command-bang).

### The `g:loaded_luainspect` option

This variable isn't really an option but if you want to avoid loading the `luainspect.vim` plug-in you can set this variable to any value in your [vimrc script](http://vimdoc.sourceforge.net/htmldoc/starting.html#vimrc):

:let g:loaded_luainspect = 1

### The `g:lua_inspect_events` option

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):
Expand Down
16 changes: 12 additions & 4 deletions luainspect.vim
Expand Up @@ -2,7 +2,7 @@
" Author: Peter Odding <peter@peterodding.com>
" Last Change: August 7, 2010
" URL: http://peterodding.com/code/vim/lua-inspect/
" Version: 0.1.9
" Version: 0.2
" License: MIT

" Don't source the plug-in when its already been loaded or &compatible is set.
Expand Down Expand Up @@ -42,7 +42,7 @@ let s:groups['SelectedVariable'] = 'Folded'

" (Automatic) command definitions. {{{1

command! LuaInspect call s:RunLuaInspect()
command! -bar -bang LuaInspect call s:RunLuaInspect(<q-bang> == '!')

augroup PluginLuaInspect
" Clear existing automatic commands.
Expand All @@ -56,12 +56,20 @@ augroup END
" Script local functions. {{{1

function! s:AutoEnable() " {{{2
if &ft == 'lua' && !&diff
if &ft == 'lua' && !&diff && !exists('b:luainspect_disabled')
LuaInspect
end
endfunction

function! s:RunLuaInspect() " {{{2
function! s:RunLuaInspect(disable) " {{{2
if a:disable
call s:ClearPreviousMatches()
unlet! b:luainspect_input b:luainspect_output
let b:luainspect_disabled = 1
return
else
unlet! b:luainspect_disabled
endif
let lines = getline(1, "$")
call insert(lines, col('.'))
call insert(lines, line('.'))
Expand Down

0 comments on commit 3e59671

Please sign in to comment.