Skip to content

Commit

Permalink
Tackle pull request #4: Allow alternative mappings
Browse files Browse the repository at this point in the history
  • Loading branch information
xolox committed Jun 17, 2014
1 parent d7fb876 commit 0e59882
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 16 deletions.
21 changes: 19 additions & 2 deletions README.md
Expand Up @@ -34,6 +34,8 @@ Note that on Windows a command prompt window pops up whenever LuaInspect is run

When you open any Lua file the semantic highlighting should be enabled automatically within a few seconds, so you don't have to configure anything if you're happy with the defaults.

## Commands

### The `:LuaInspect` command

You don't need to use this command unless you've disabled automatic highlighting using `g:lua_inspect_events`. When you execute this command the plug-in runs the LuaInspect tool and then highlights all variables in the current buffer using one of the following highlighting groups:
Expand Down Expand Up @@ -64,12 +66,27 @@ By default the semantic highlighting and the warning messages in the location li
imap <F6> <C-o>:LuaInspectToggle<CR>
nmap <F6> :LuaInspectToggle<CR>

### The `:LuaInspectRename` command

This command renames the variable under the cursor. It's used to define the `<F2>` mapping and can be used if you don't like the default mappings and want to define your own.

### The `:LuaInspectGoTo` command

This command jumps to the definition of the variable under the cursor. It's used to define the `gd` mapping and can be used if you don't like the default mappings and want to define your own.

## Options

### 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] [vimrc]:

:let g:loaded_luainspect = 1


### The `g:lua_inspect_mappings` option

If this is set to true (1, the default value) then the `<F2>` and `gd` mappings are defined in Lua buffers (as buffer local mappings). You can set it to false (0) to disable the default mappings (so you can define your own).

### The `g:lua_inspect_warnings` option

When LuaInspect reports warnings about unused variables, wrong argument counts, etc. they are automatically shown in a [location list window] [location-list]. If you don't like this add the following to your [vimrc script] [vimrc]:
Expand Down Expand Up @@ -100,8 +117,8 @@ If you have questions, bug reports, suggestions, etc. the author can be contacte

## License

This software is licensed under the [MIT license] [mit].
© 2013 Peter Odding &lt;<peter@peterodding.com>&gt;.
This software is licensed under the [MIT license] [mit].
© 2014 Peter Odding &lt;<peter@peterodding.com>&gt;.

The source code repository and distributions contain bundled copies of
LuaInspect and Metalua, please refer to their licenses (also included).
Expand Down
12 changes: 7 additions & 5 deletions autoload/xolox/luainspect.vim
@@ -1,9 +1,9 @@
" Vim script.
" Author: Peter Odding <peter@peterodding.com>
" Last Change: August 19, 2013
" Last Change: June 17, 2014
" URL: http://peterodding.com/code/vim/lua-inspect/

let g:xolox#luainspect#version = '0.5.1'
let g:xolox#luainspect#version = '0.5.2'

function! xolox#luainspect#toggle_cmd() " {{{1
if !(exists('b:luainspect_disabled') && b:luainspect_disabled)
Expand All @@ -20,9 +20,11 @@ function! xolox#luainspect#auto_enable() " {{{1
" Disable easytags.vim because it doesn't play nice with luainspect.vim!
let b:easytags_nohl = 1
" Define buffer local mappings for rename / goto definition features.
inoremap <buffer> <silent> <F2> <C-o>:call xolox#luainspect#make_request('rename')<CR>
nnoremap <buffer> <silent> <F2> :call xolox#luainspect#make_request('rename')<CR>
nnoremap <buffer> <silent> gd :call xolox#luainspect#make_request('go_to')<CR>
if g:lua_inspect_mappings
inoremap <buffer> <silent> <F2> <C-o>:LuaInspectRename<CR>
nnoremap <buffer> <silent> <F2> :LuaInspectRename<CR>
nnoremap <buffer> <silent> gd :LuaInspectGoTo<CR>
endif
" Enable balloon evaluation / dynamic tool tips.
if has('balloon_eval')
setlocal ballooneval balloonexpr=LuaInspectToolTip()
Expand Down
50 changes: 42 additions & 8 deletions doc/luainspect.txt
Expand Up @@ -6,15 +6,20 @@ Contents ~
1. Introduction |luainspect-introduction|
2. Installation |luainspect-installation|
3. Usage |luainspect-usage|
4. Commands |luainspect-commands|
1. The |:LuaInspect| command
2. The |:LuaInspectToggle| command
3. The |g:loaded_luainspect| option
4. The |g:lua_inspect_warnings| option
5. The |g:lua_inspect_events| option
6. The |g:lua_inspect_internal| option
4. Contact |luainspect-contact|
5. License |luainspect-license|
6. References |luainspect-references|
3. The |:LuaInspectRename| command
4. The |:LuaInspectGoTo| command
5. Options |luainspect-options|
1. The |g:loaded_luainspect| option
2. The |g:lua_inspect_mappings| option
3. The |g:lua_inspect_warnings| option
4. The |g:lua_inspect_events| option
5. The |g:lua_inspect_internal| option
6. Contact |luainspect-contact|
7. License |luainspect-license|
8. References |luainspect-references|

===============================================================================
*luainspect-introduction*
Expand Down Expand Up @@ -85,6 +90,10 @@ When you open any Lua file the semantic highlighting should be enabled
automatically within a few seconds, so you don't have to configure anything if
you're happy with the defaults.

===============================================================================
*luainspect-commands*
Commands ~

-------------------------------------------------------------------------------
The *:LuaInspect* command

Expand Down Expand Up @@ -130,6 +139,24 @@ of choice in your |vimrc| script though. For example:
imap <F6> <C-o>:LuaInspectToggle<CR>
nmap <F6> :LuaInspectToggle<CR>
<
-------------------------------------------------------------------------------
The *:LuaInspectRename* command

This command renames the variable under the cursor. It's used to define the
'<F2>' mapping and can be used if you don't like the default mappings and want
to define your own.

-------------------------------------------------------------------------------
The *:LuaInspectGoTo* command

This command jumps to the definition of the variable under the cursor. It's
used to define the 'gd' mapping and can be used if you don't like the default
mappings and want to define your own.

===============================================================================
*luainspect-options*
Options ~

-------------------------------------------------------------------------------
The *g:loaded_luainspect* option

Expand All @@ -139,6 +166,13 @@ script:
>
:let g:loaded_luainspect = 1
<
-------------------------------------------------------------------------------
The *g:lua_inspect_mappings* option

If this is set to true (1, the default value) then the '<F2>' and 'gd' mappings
are defined in Lua buffers (as buffer local mappings). You can set it to false
(0) to disable the default mappings (so you can define your own).

-------------------------------------------------------------------------------
The *g:lua_inspect_warnings* option

Expand Down Expand Up @@ -188,7 +222,7 @@ lua-inspect. If you like this plug-in please vote for it on Vim Online [14].
*luainspect-license*
License ~

This software is licensed under the MIT license [15]. Š 2013 Peter Odding
This software is licensed under the MIT license [15]. Š 2014 Peter Odding
<peter@peterodding.com>.

The source code repository and distributions contain bundled copies of
Expand Down
13 changes: 12 additions & 1 deletion plugin/luainspect.vim
@@ -1,6 +1,6 @@
" Vim plug-in
" Author: Peter Odding <peter@peterodding.com>
" Last Change: August 19, 2013
" Last Change: June 17, 2014
" URL: http://peterodding.com/code/vim/lua-inspect/

" Support for automatic update using the GLVS plug-in.
Expand All @@ -24,6 +24,11 @@ catch
finish
endtry

if !exists('g:lua_inspect_mappings')
" Change this to disable default key mappings.
let g:lua_inspect_mappings = 1
endif

if !exists('g:lua_inspect_warnings')
" Change this to disable automatic warning messages.
let g:lua_inspect_warnings = 1
Expand Down Expand Up @@ -55,6 +60,12 @@ 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()

" This command can be used to rename variables.
command! -bar LuaInspectRename call xolox#luainspect#make_request('rename')

" This command can be used to jump to a variable's definition.
command! -bar LuaInspectGoTo call xolox#luainspect#make_request('go_to')

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

0 comments on commit 0e59882

Please sign in to comment.