CompleteParameter is a plugin for complete function's parameters after complete a function.
If you like this plugin, please star it.
Without CompleteParameter, only insert the function name.
With CompleteParameter, insert the function name and parameters. You can jump to
the next parameter use <c-j>
and jump to the previous parameter use <c-k>
.
set noshowmode
or set cmdheight=2
) I suggest you to use a plugin manager, such vim-plug or other.
Plug 'tenfyzhong/CompleteParameter.vim'
git clone https://github.com/tenfyzhong/CompleteParameter.vim.git ~/.vim/bundle/CompleteParameter.vim
echo 'set rtp+=~/.vim/bundle/CompleteParameter.vim' >> ~/.vimrc
vim -c 'helptag ~/.vim/bundle/CompleteParameter.vim/doc' -c qa!
Install a complete engine have supported. Goto the completion item of the
completion popup menu you want to select, and then type (
(minimal setting),
the parameters will be inserted and select the the first parameter.
<c-j>
/<c-k>
(minimal setting) will jump to the next/previous parameter
and select it.
inoremap <silent><expr> ( complete_parameter#pre_complete("()")
smap <c-j> <Plug>(complete_parameter#goto_next_parameter)
imap <c-j> <Plug>(complete_parameter#goto_next_parameter)
smap <c-k> <Plug>(complete_parameter#goto_previous_parameter)
imap <c-k> <Plug>(complete_parameter#goto_previous_parameter)
The parameter of complete_parameter#pre_complete
will be insert if
parameter completion failed.
<Plug>(complete_parameter#goto_next_parameter)
Goto next parameter and select it.
eg:
nmap <c-j> <Plug>(complete_parameter#goto_next_parameter)
imap <c-j> <Plug>(complete_parameter#goto_next_parameter)
smap <c-j> <Plug>(complete_parameter#goto_next_parameter)
<Plug>(complete_parameter#goto_previous_parameter)
Goto previous parameter and select it.
eg:
nmap <c-k> <Plug>(complete_parameter#goto_previous_parameter)
imap <c-k> <Plug>(complete_parameter#goto_previous_parameter)
smap <c-k> <Plug>(complete_parameter#goto_previous_parameter)
<Plug>(complete_parameter#overload_down)
Select next overload function.
eg:
nmap <m-d> <Plug>(complete_parameter#overload_down)
imap <m-d> <Plug>(complete_parameter#overload_down)
smap <m-d> <Plug>(complete_parameter#overload_down)
<Plug>(complete_parameter#overload_up)
Select previous overload function.
eg:
nmap <m-u> <Plug>(complete_parameter#overload_up)
imap <m-u> <Plug>(complete_parameter#overload_up)
smap <m-u> <Plug>(complete_parameter#overload_up)
g:complete_parameter_log_level
optionThis option set the log level.
5: disable log.
4: only print error log.
2: print error and debug log.
1: print error, debug, trace log.
Default: 5
let g:complete_parameter_log_level = 5
g:complete_parameter_use_ultisnips_mappings
optionIf this option is 1 and you use ultisnips together, it will use ultisnips mapping
to goto next or previous parameter.
default: 0
let g:complete_parameter_use_ultisnips_mapping = 0
g:complete_parameter_echo_signature
optionIt will echo signature if this option is 1. (need to set noshowmode
or set cmdheight=2
)
default: 1
let g:complete_parameter_echo_signature = 1
g:complete_parameter_py_keep_value
optionIt will keep default value if this option is 1 for python.
For example, if the definition is def foo(a=1, b=2)
, it will complete
(a=1, b=2)
if its value is 1. Otherwise, it will complete (a, b)
.
If there are =
in the completion, the jump to action only select the value,
but not parameter name. It will select 1
and then 2
in the previous
example.
default: 1
let g:complete_parameter_py_keep_value = 1
g:complete_parameter_py_remove_default
optionIt will remove default parametrs if this option is 1 for python.
For example, if the definition is def foo(a, b=1)
, it will complete
(a)
if its value is 1. Otherwise, it will complete (a, b)
.
default: 1
let g:complete_parameter_py_remove_default = 1
The cell mark √
means the completion engine has supported the language by itself.
Of course, you must install the completion engine for the language follow its document.
The plugin in the cell was supported with the completion engine.
YouCompleteMe | deoplete | neocomplete | clang_complete | |
---|---|---|---|---|
c | √ | deoplete-clang | clang_complete | √ |
cpp | √ | deoplete-clang | clang_complete | √ |
go | √ | vim-go | vim-go | |
python | √ | deoplete-jedi | jedi-vim | |
rust | √ | deoplete-rust | vim-racer | |
javascript | √ | deoplete-ternjs | tern_for_vim | |
typescript | √ | nvim-typescript | tsuquyomi | |
erlang | vim-erlang-omnicomplete | vim-erlang-omnicomplete | vim-erlang-omnicomplete |
vim-racer
let g:racer_experimental_completer = 1
tern_for_vim
if !exists('g:neocomplete#force_omni_input_patterns')
let g:neocomplete#force_omni_input_patterns = {}
endif
let g:neocomplete#force_omni_input_patterns.javascript = '[^. \t]\.\w*'
tsuquyomi
let g:tsuquyomi_completion_detail = 1
if !exists('g:neocomplete#force_omni_input_patterns')
let g:neocomplete#force_omni_input_patterns = {}
endif
let g:neocomplete#force_omni_input_patterns.typescript = '[^. *\t]\.\w*\|\h\w*::'
(
Because the auto-pairs use inoremap
to mapping the keys. It can't call this
plugin after the auto-pairs process. You can add the following setting to you
.vimrc, and it'll work well.
let g:AutoPairs = {'[':']', '{':'}',"'":"'",'"':'"', '`':'`'}
inoremap <buffer><silent> ) <C-R>=AutoPairsInsert(')')<CR>
If you use ultinsips
, you must load ultisnips
before this plugin. In other
words, if you use plug
to load plugins, Plug 'SirVer/ultisnips'
must before
Plug 'tenfyzhong/CompleteParameter.vim'
in your vimrc.
You can type <c-y>
key to accept the selected function and stop completion.
When the popup menu is disappeared, the parameters will not be insert.
<c-j>
doesn't jump to the next parameter, but delete the selected words.If you use neosnippet, Please set g:neosnippet#disable_select_mode_mappings
to 0. It will remove all select mappings.
If you don't use neosnippet, please send me a issue, and give me the plugins
you are using.
Contributions and pull requests are welcome.
MIT License Copyright (c) 2017 tenfyzhong