Skip to content

Commit 1ed6e7a

Browse files
committed
New :LuaInspectToggle command
1 parent befaf4b commit 1ed6e7a

File tree

4 files changed

+49
-6
lines changed

4 files changed

+49
-6
lines changed

README.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,18 @@ You don't need to use this command unless you've disabled automatic highlighting
4545
* <span style="border-bottom: 1px dotted green">luaInspectWrongArgCount</span>
4646
* <span style="border-bottom: 1px dotted red">luaInspectSyntaxError</span>
4747

48-
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).
48+
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).
49+
50+
### The `:LuaInspectToggle` command
51+
52+
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:
53+
54+
" Don't enable the lua-inspect plug-in automatically in Lua buffers.
55+
let g:lua_inspect_events = ''
56+
57+
" Enable/disable the lua-inspect plug-in manually using <F6>.
58+
imap <F6> <C-o>:LuaInspectToggle<CR>
59+
nmap <F6> :LuaInspectToggle<CR>
4960

5061
### The `g:loaded_luainspect` option
5162

autoload/xolox/luainspect.vim

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
11
" Vim script.
22
" Author: Peter Odding <peter@peterodding.com>
3-
" Last Change: September 26, 2011
3+
" Last Change: November 16, 2011
44
" URL: http://peterodding.com/code/vim/lua-inspect/
55

6-
let g:xolox#luainspect#version = '0.4.13'
6+
let g:xolox#luainspect#version = '0.4.14'
7+
8+
function! xolox#luainspect#toggle_cmd() " {{{1
9+
if !(exists('b:luainspect_disabled') && b:luainspect_disabled)
10+
" Enabled -> disabled.
11+
call xolox#luainspect#highlight_cmd(1)
12+
else
13+
" Disabled -> enabled.
14+
call xolox#luainspect#highlight_cmd(0)
15+
endif
16+
endfunction
717

818
function! xolox#luainspect#auto_enable() " {{{1
919
if !&diff && !exists('b:luainspect_disabled')

doc/luainspect.txt

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,28 @@ current buffer using one of the following highlighting groups:
9090
If you don't like one or more of the default styles the Vim documentation
9191
describes how to change them (see |:hi-default|). If you want to disable the
9292
semantic highlighting in a specific Vim buffer execute ':LuaInspect!' in that
93-
buffer. When you want to reenable the highlighting execute |:LuaInspect|
93+
buffer. When you want to re-enable the highlighting execute |:LuaInspect|
9494
again, but now without the bang (see |:command-bang|).
9595

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

plugin/luainspect.vim

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
" Vim plug-in
22
" Author: Peter Odding <peter@peterodding.com>
3-
" Last Change: August 27, 2011
3+
" Last Change: November 15, 2011
44
" URL: http://peterodding.com/code/vim/lua-inspect/
55

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

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

42+
" This command can be used as a toggle to enable/disable the highlighting.
43+
command! -bar LuaInspectToggle call xolox#luainspect#toggle_cmd()
44+
4245
" Automatically enable the plug-in in Lua buffers.
4346
augroup PluginLuaInspect
4447
autocmd! FileType lua call xolox#luainspect#auto_enable()

0 commit comments

Comments
 (0)