Skip to content

Commit

Permalink
Fix #6. Add option to define the mapping mode.
Browse files Browse the repository at this point in the history
option `g:complete_parameter_goto_next_mode`
support define goto next mapping mode.

option `g:complete_parameter_goto_previous_mode`
support define goto previous mapping mode.

option `g:complete_parameter_mapping_overload_down_mode`
support define overload down mapping mode.

`g:complete_parameter_mapping_overload_up_mode`
support define overload up mapping mode.
  • Loading branch information
tenfyzhong committed Jun 17, 2017
1 parent 666067e commit 189ae08
Show file tree
Hide file tree
Showing 6 changed files with 327 additions and 17 deletions.
4 changes: 4 additions & 0 deletions CHANGLOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
0.1.2:
Support typescript.
Add g:complete_parameter_goto_next_mode option.
Add g:complete_parameter_goto_previous_mode option.
Add g:complete_parameter_mapping_overload_down_mode option.
Add g:complete_parameter_mapping_overload_up_mode option.

0.1.1: 2017-06-15
Fix travis-ci test.
Expand Down
49 changes: 45 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,24 @@ and select it.

# Mapping
### `(`
Call the parameter completor.
Mapping type: inoremap
Call the parameter completor.

### `<m-n>`
Goto the next parameter and select it.
Mapping type: inoremap,nnoremap,vnoremap
Goto the next parameter and select it.

### `<m-p>`
Mapping type: inoremap,nnoremap,vnoremap
Goto the previous parameter and select it.

### `<m-d>`
Select the next overload function.
Mapping type: inoremap,nnoremap,vnoremap
Select the next overload function.

### `<m-u>`
Select the previous overload function.
Mapping type: inoremap,nnoremap,vnoremap
Select the previous overload function.

# Options
### The `g:complete_parameter_mapping_complete` option
Expand Down Expand Up @@ -104,6 +109,15 @@ Default: `<m-n>`
let g:complete_parameter_mapping_goto_next = '<m-n>'
```

### The `g:complete_parameter_goto_next_mode` option
This option set the mapping `g:complete_parameter_mapping_goto_next` mode.
For example, the value is `iv`, it'll only map
`g:complete_parameter_mapping_goto_next` in the mode of insert and visual(select).
Default: `ivn`
```viml
let g:complete_parameter_goto_next_mode = 'ivn'
```

### The `g:complete_parameter_mapping_goto_previous` option
This option set the goto to previous paramater mapping. When this mapping was called,
it'll goto to the previous parameter.
Expand All @@ -112,6 +126,15 @@ Default: `<m-p>`
let g:complete_parameter_mapping_goto_previous = '<m-p>'
```

### The `g:complete_parameter_goto_previous_mode` option
This option set the mapping `g:complete_parameter_mapping_goto_previous` mode.
For example, the value is `iv`, it'll only map
`g:complete_parameter_mapping_goto_previous` in the mode of insert and visual(select).
Default: `ivn`
```viml
let g:complete_parameter_goto_previous_mode = 'ivn'
```

### The `g:complete_parameter_mapping_overload_down` option
This option set the select next overload parameters mapping. When this
mapping was called, it'll delete the current completed paramaters and insert
Expand All @@ -123,6 +146,15 @@ Default: `<m-d>`
let g:complete_parameter_mapping_overload_down = '<m-d>'
```

### The `g:complete_parameter_mapping_overload_down_mode` option
This option set the mapping `g:complete_parameter_mapping_overload_down` mode.
For example, the value is `iv`, it'll only map
`g:complete_parameter_mapping_overload_down` in the mode of insert and visual(select).
Default: `ivn`
```viml
let g:complete_parameter_mapping_overload_down_mode = 'ivn'
```

### The `g:complete_parameter_mapping_overload_up` option
This option set the select previous overload parameters mapping. When this
mapping was called, it'll delete the current completed paramaters and insert
Expand All @@ -134,6 +166,15 @@ Default: `<m-u>`
let g:complete_parameter_mapping_overload_up = '<m-u>'
```

### The `g:complete_parameter_mapping_overload_up_mode` option
This option set the mapping `g:complete_parameter_mapping_overload_up` mode.
For example, the value is `iv`, it'll only map
`g:complete_parameter_mapping_overload_up` in the mode of insert and visual(select).
Default: `ivn`
```viml
let g:complete_parameter_mapping_overload_up_mode = 'ivn'
```

### The `g:complete_parameter_log_level` option
This option set the log level.
4: only print **error** log.
Expand Down
36 changes: 27 additions & 9 deletions autoload/complete_parameter.vim
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,18 @@ function! s:mapping_complete(key, failed_insert) "{{{
endfunction "}}}

" mapping goto parameter and select overload function
function! s:mapping_action(key, action) "{{{
exec 'inoremap <silent>' . a:key . ' ' . a:action
exec 'nnoremap <silent>' . a:key . ' ' . a:action
exec 'xnoremap <silent>' . a:key . ' ' . a:action
exec 'vnoremap <silent>' . a:key . ' ' . a:action
function! complete_parameter#mapping_action(key, action, mode) "{{{
let l:mode = a:mode
if empty(l:mode)
return
endif
let mode_list = split(l:mode, '\zs')
for m in mode_list
if m !~# '[inv]'
continue
endif
exec m.'noremap <silent>' . a:key . ' ' . a:action
endfor
endfunction "}}}

function! s:init_filetype_mapping() "{{{
Expand Down Expand Up @@ -67,19 +74,30 @@ function! complete_parameter#init() "{{{

let g:complete_parameter_mapping_goto_next = get(g:, 'complete_parameter_mapping_goto_next', '')
let s:complete_parameter_mapping_goto_next = g:complete_parameter_mapping_goto_next != '' ? g:complete_parameter_mapping_goto_next : '<m-n>'
let g:complete_parameter_goto_next_mode = get(g:, 'complete_parameter_goto_next_mode', '')
let s:complete_parameter_goto_next_mode = g:complete_parameter_goto_next_mode != '' ? g:complete_parameter_goto_next_mode : 'inv'

let g:complete_parameter_mapping_goto_previous = get(g:, 'complete_parameter_mapping_goto_previous', '')
let s:complete_parameter_mapping_goto_previous = g:complete_parameter_mapping_goto_previous != '' ? g:complete_parameter_mapping_goto_previous : '<m-p>'
let g:complete_parameter_goto_previous_mode = get(g:, 'complete_parameter_goto_previous_mode', '')
let s:complete_parameter_goto_previous_mode = g:complete_parameter_goto_previous_mode != '' ? g:complete_parameter_goto_previous_mode : 'inv'

let g:complete_parameter_mapping_overload_up = get(g:, 'complete_parameter_mapping_overload_up', '<m-u>')
let s:complete_parameter_mapping_overload_up = g:complete_parameter_mapping_overload_up != '' ? g:complete_parameter_mapping_overload_up : '<m-u>'
let g:complete_parameter_mapping_overload_up_mode = get(g:, 'complete_parameter_mapping_overload_up_mode', '')
let s:complete_parameter_mapping_overload_up_mode = g:complete_parameter_mapping_overload_up_mode != '' ? g:complete_parameter_mapping_overload_up_mode : 'inv'

let g:complete_parameter_mapping_overload_down = get(g:, 'complete_parameter_mapping_overload_down', '<m-d>')
let s:complete_parameter_mapping_overload_down = g:complete_parameter_mapping_overload_down != '' ? g:complete_parameter_mapping_overload_down : '<m-d>'
let g:complete_parameter_mapping_overload_down_mode = get(g:, 'complete_parameter_mapping_overload_down_mode', '')
let s:complete_parameter_mapping_overload_down_mode = g:complete_parameter_mapping_overload_down_mode != '' ? g:complete_parameter_mapping_overload_down_mode : 'inv'


call <SID>mapping_complete(s:complete_parameter_mapping_complete, s:complete_parameter_failed_insert)
call <SID>mapping_action(s:complete_parameter_mapping_goto_next, '<ESC>:call complete_parameter#goto_next_param(1)<cr>')
call <SID>mapping_action(s:complete_parameter_mapping_goto_previous, '<ESC>:call complete_parameter#goto_next_param(0)<cr>')
call <SID>mapping_action(s:complete_parameter_mapping_overload_down, '<ESC>:call complete_parameter#overload_next(1)<cr>')
call <SID>mapping_action(s:complete_parameter_mapping_overload_up, '<ESC>:call complete_parameter#overload_next(0)<cr>')
call complete_parameter#mapping_action(s:complete_parameter_mapping_goto_next, '<ESC>:call complete_parameter#goto_next_param(1)<cr>', s:complete_parameter_goto_next_mode)
call complete_parameter#mapping_action(s:complete_parameter_mapping_goto_previous, '<ESC>:call complete_parameter#goto_next_param(0)<cr>', s:complete_parameter_goto_previous_mode)
call complete_parameter#mapping_action(s:complete_parameter_mapping_overload_up, '<ESC>:call complete_parameter#overload_next(0)<cr>', s:complete_parameter_mapping_overload_up_mode)
call complete_parameter#mapping_action(s:complete_parameter_mapping_overload_down, '<ESC>:call complete_parameter#overload_next(1)<cr>', s:complete_parameter_mapping_overload_down_mode)
endfunction "}}}

let s:ftfunc_prefix = 'cm_parser#'
Expand Down
41 changes: 37 additions & 4 deletions doc/complete_parameter.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,20 @@ Mapping type: inoremap
Call the parameter completor.

* <m-n> *<m-n>*
Mapping type: inoremap,nnoremap,xnoremap,vnoremap
Mapping type: inoremap,nnoremap,vnoremap
Goto the next parameter and select it.

* <m-p> *<m-p>*
Mapping type: inoremap,nnoremap,xnoremap,vnoremap
Mapping type: inoremap,nnoremap,vnoremap
Goto the previous parameter and select it.

* <m-d> *<m-d>*
Mapping type: inoremap,nnoremap,xnoremap,vnoremap
Mapping type: inoremap,nnoremap,vnoremap
Select the next overload function.

* <m-u> *<m-u>*
Mapping type: inoremap,nnoremap,xnoremap,vnoremap
Mapping type: inoremap,nnoremap,vnoremap
Select the previous overload function.

================================================================================
4. Options *complete-parameter-options*
Expand Down Expand Up @@ -105,13 +106,29 @@ This option set the goto to next paramater mapping. When this mapping was called
it'll goto to the next parameter.
Default: '<m-n>' >
let g:complete_parameter_mapping_goto_next = '<m-n>'
<
*g:complete_parameter_goto_next_mode*
* g:complete_parameter_goto_next_mode
This option set the mapping |g:complete_parameter_mapping_goto_next| mode.
For example, the value is 'iv', it'll only map
|g:complete_parameter_mapping_goto_next| in the mode of insert and visual(select).
Default: 'ivn' >
let g:complete_parameter_goto_next_mode = 'ivn'
<
*g:complete_parameter_mapping_goto_previous*
* g:complete_parameter_mapping_goto_previous
This option set the goto to previous paramater mapping. When this mapping was called,
it'll goto to the previous parameter.
Default: '<m-p>' >
let g:complete_parameter_mapping_goto_previous = '<m-p>'
<
*g:complete_parameter_goto_previous_mode*
* g:complete_parameter_goto_previous_mode
This option set the mapping |g:complete_parameter_mapping_goto_previous| mode.
For example, the value is 'iv', it'll only map
|g:complete_parameter_mapping_goto_previous| in the mode of insert and visual(select).
Default: 'ivn' >
let g:complete_parameter_goto_previous_mode = 'ivn'
<
*g:complete_parameter_mapping_overload_down*
* g:complete_parameter_mapping_overload_down
Expand All @@ -122,6 +139,14 @@ completed parameters. For example, `v.erase(__first, __last)`, only the cursor
in the `(` and `)`, it can be work.
Default: '<m-d>' >
let g:complete_parameter_mapping_overload_down = '<m-d>'
<
*g:complete_parameter_mapping_overload_down_mode*
* g:complete_parameter_mapping_overload_down_mode
This option set the mapping |g:complete_parameter_mapping_overload_down| mode.
For example, the value is 'iv', it'll only map
|g:complete_parameter_mapping_overload_down| in the mode of insert and visual(select).
Default: 'ivn' >
let g:complete_parameter_mapping_overload_down_mode = 'ivn'
<
*g:complete_parameter_mapping_overload_up*
* g:complete_parameter_mapping_overload_up
Expand All @@ -132,6 +157,14 @@ completed parameters. For example, `v.erase(__first, __last)`, only the cursor
in the `(` and `)`, it can be work.
Default: '<m-u>' >
let g:complete_parameter_mapping_overload_up = '<m-u>'
<
*g:complete_parameter_mapping_overload_up_mode*
* g:complete_parameter_mapping_overload_up_mode
This option set the mapping |g:complete_parameter_mapping_overload_up| mode.
For example, the value is 'iv', it'll only map
|g:complete_parameter_mapping_overload_up| in the mode of insert and visual(select).
Default: 'ivn' >
let g:complete_parameter_mapping_overload_up_mode = 'ivn'
<
*g:complete_parameter_log_level*
* g:complete_parameter_log_level
Expand Down
Loading

0 comments on commit 189ae08

Please sign in to comment.