Skip to content

Commit

Permalink
New :LuaInspectToggle command
Browse files Browse the repository at this point in the history
  • Loading branch information
xolox committed Nov 15, 2011
1 parent befaf4b commit 1ed6e7a
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 6 deletions.
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,18 @@ You don't need to use this command unless you've disabled automatic highlighting
* <span style="border-bottom: 1px dotted green">luaInspectWrongArgCount</span>
* <span style="border-bottom: 1px dotted red">luaInspectSyntaxError</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). 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).
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 re-enable the highlighting execute `:LuaInspect` again, but now without the [bang](http://vimdoc.sourceforge.net/htmldoc/map.html#:command-bang).

### The `:LuaInspectToggle` command

By default the semantic highlighting and the warning messages in the location list window are automatically applied to Lua buffers and updated every once in a while, but this can be disabled by setting `g:lua_inspect_events` to an empty string in your [vimrc script] [vimrc]. If the plug-in is not automatically enabled then it may be useful to enable/disable it using a key mapping. That's what the `:LuaInspectToggle` command is for. You still have to define your key mapping of choice in your [vimrc script] [vimrc] though. For example:

" Don't enable the lua-inspect plug-in automatically in Lua buffers.
let g:lua_inspect_events = ''

" Enable/disable the lua-inspect plug-in manually using <F6>.
imap <F6> <C-o>:LuaInspectToggle<CR>
nmap <F6> :LuaInspectToggle<CR>

### The `g:loaded_luainspect` option

Expand Down
14 changes: 12 additions & 2 deletions autoload/xolox/luainspect.vim
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
" Vim script.
" Author: Peter Odding <peter@peterodding.com>
" Last Change: September 26, 2011
" Last Change: November 16, 2011
" URL: http://peterodding.com/code/vim/lua-inspect/

let g:xolox#luainspect#version = '0.4.13'
let g:xolox#luainspect#version = '0.4.14'

function! xolox#luainspect#toggle_cmd() " {{{1
if !(exists('b:luainspect_disabled') && b:luainspect_disabled)
" Enabled -> disabled.
call xolox#luainspect#highlight_cmd(1)
else
" Disabled -> enabled.
call xolox#luainspect#highlight_cmd(0)
endif
endfunction

function! xolox#luainspect#auto_enable() " {{{1
if !&diff && !exists('b:luainspect_disabled')
Expand Down
21 changes: 20 additions & 1 deletion doc/luainspect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,28 @@ current buffer using one of the following highlighting groups:
If you don't like one or more of the default styles the Vim documentation
describes how to change them (see |: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|
buffer. When you want to re-enable the highlighting execute |:LuaInspect|
again, but now without the bang (see |:command-bang|).

-------------------------------------------------------------------------------
The *:LuaInspectToggle* command

By default the semantic highlighting and the warning messages in the location
list window are automatically applied to Lua buffers and updated every once in
a while, but this can be disabled by setting |g:lua_inspect_events| to an
empty string in your [vimrc script] [vimrc]. If the plug-in is not
automatically enabled then it may be useful to enable/disable it using a key
mapping. That's what the |:LuaInspectToggle| command is for. You still have to
define your key mapping of choice in your [vimrc script] [vimrc] though. For
example:
>
" Don't enable the lua-inspect plug-in automatically in Lua buffers.
let g:lua_inspect_events = ''
" Enable/disable the lua-inspect plug-in manually using <F6>.
imap <F6> <C-o>:LuaInspectToggle<CR>
nmap <F6> :LuaInspectToggle<CR>
-------------------------------------------------------------------------------
The *g:loaded_luainspect* option

Expand Down
7 changes: 5 additions & 2 deletions plugin/luainspect.vim
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
" Vim plug-in
" Author: Peter Odding <peter@peterodding.com>
" Last Change: August 27, 2011
" Last Change: November 15, 2011
" URL: http://peterodding.com/code/vim/lua-inspect/

" Support for automatic update using the GLVS plug-in.
Expand Down Expand Up @@ -36,9 +36,12 @@ if !exists('g:lua_inspect_internal')
let g:lua_inspect_internal = has('lua')
endif

" This command updates highlighting when automatic highlighting is disabled.
" This command enables/updates highlighting when automatic highlighting is disabled.
command! -bar -bang LuaInspect call xolox#luainspect#highlight_cmd(<q-bang> == '!')

" This command can be used as a toggle to enable/disable the highlighting.
command! -bar LuaInspectToggle call xolox#luainspect#toggle_cmd()

" Automatically enable the plug-in in Lua buffers.
augroup PluginLuaInspect
autocmd! FileType lua call xolox#luainspect#auto_enable()
Expand Down

0 comments on commit 1ed6e7a

Please sign in to comment.