1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-23 07:20:04 +08:00

Fix complete_parameter support (#3738)

This commit is contained in:
Wang Shidong 2020-08-29 21:14:10 +08:00 committed by GitHub
parent 7217abeaa8
commit 38b994813b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
40 changed files with 4430 additions and 3 deletions

View File

@ -102,13 +102,17 @@ function! SpaceVim#layers#autocomplete#plugins() abort
endif
endif
if has('patch-7.4.774')
" both echodoc and CompleteParameter requires
" vim patch-7.4.744
" v:completed_item
call add(plugins, ['Shougo/echodoc.vim', {
\ 'on_cmd' : ['EchoDocEnable', 'EchoDocDisable'],
\ 'on_event' : 'CompleteDone',
\ 'loadconf_before' : 1,
\ }])
call add(plugins, [g:_spacevim_root_dir . 'bundle/CompleteParameter.vim',
\ { 'merged' : 0}])
endif
call add(plugins, ['tenfyzhong/CompleteParameter.vim', {'merged': 0}])
return plugins
endfunction
@ -117,7 +121,8 @@ function! SpaceVim#layers#autocomplete#config() abort
if g:spacevim_autocomplete_parens
imap <expr>(
\ pumvisible() ?
\ complete_parameter#pre_complete("()") :
\ has('patch-7.4.744') ?
\ complete_parameter#pre_complete("()") : '(' :
\ (len(maparg('<Plug>delimitMate(', 'i')) == 0) ?
\ "\<Plug>delimitMate(" :
\ '('

View File

@ -21,7 +21,7 @@ if g:spacevim_snippet_engine ==# 'neosnippet'
return "\<plug>(neosnippet_expand_or_jump)"
elseif pumvisible()
return "\<C-n>"
elseif complete_parameter#jumpable(1) && getline('.')[col('.')-2] !=# ')'
elseif has('patch-7.4.774') && complete_parameter#jumpable(1) && getline('.')[col('.')-2] !=# ')'
return "\<plug>(complete_parameter#goto_next_parameter)"
else
return "\<tab>"

View File

@ -0,0 +1,59 @@
<!--
Before submitting
=================
- Make sure that you have the latest version of CompleteParameter.vim.
- Check if your problem is reproducible with a minimal configuration
- Attach screenshots.
-->
# Issue Prelude
<!-- Check all that apply [x] -->
- Category
- [ ] Question
- [ ] Bug
- [ ] Suggestion
- OS
- [ ] Linux
- [ ] macOS
- [ ] Windows
- [ ] Etc.
- Vim
- [ ] Vim
- [ ] Neovim
- Language
- [ ] C
- [ ] C++
- [ ] go
- [ ] python
- [ ] rust
- [ ] javascript
- [ ] typescript
- [ ] erlang
# Completion Engine and Commit SHA
<!--
example:
YouCompleteMe: 369fdad
-->
# Minimal Configuration
# Issue Details
<!--
What happended and what do you expect to happend?
-->
# Messages
<!--
If filing a bug report, follow the steps to get the message.
1. Execute `let g:complete_parameter_log_level = 1`.
2. Replay you action.
3. Execute `messages`.
4. Paste the messages or send a gist.
-->

View File

@ -0,0 +1,8 @@
<!--
Thank you for working on ComplateParameter!
Please include tests for the PR.
-->
# Why this change is necessary and useful
<!--Please explain **in detail** why the changes in this PR are needed.-->

View File

@ -0,0 +1,22 @@
language: vim
sudo: required
dist: trusty
os:
- linux
- osx
env:
- VIM_NAME=vim
- VIM_NAME=nvim
install:
- bash ./ci/travis_install.sh
- export PATH="$HOME/vim/bin:$PATH"
- if [[ "$TRAVIS_OS_NAME" == 'osx' ]] && [[ "$VIM_NAME" == 'nvim' ]]; then export PATH="./nvim-osx64/bin:$PATH"; fi
before_script: |
git clone --depth 1 https://github.com/junegunn/vader.vim.git
script: bash ./ci/travis_script.sh $VIM_NAME

View File

@ -0,0 +1,128 @@
0.8.2: 2018-11-17
Python, support echo signature
0.8.0: 2018-08-06
Add option g:complete_parameter_py_remove_default.
Suppoert remove python default parameter.
0.7.2:2018-06-12
Modify c and ts parameters.
0.7.1: 2017-10-21
Format log.
Disable log by default.
0.7.0: 2017-10-03
Support c/c++ macro.
Fix '<' or '>' selected.
Fix python parser.
0.6.4: 2017-09-29
Fix can't goto_previous_parameter when selection is exclusive.
0.6.3: 2017-09-28
Select one more char when selection is exclusive.
0.6.2: 2017-09-10
Fix helptags error.
0.6.1: 2017-09-10
Python support keep default value and select the value only.
Add option g:complete_parameter_py_keep_value.
Support jeci.
0.6.0: 2017-08-19
Rename file.
Insert parameter if there are some content after the cursor.
Fix bug.
0.5.0: 2017-08-09
show signature.
0.4.0: 2017-08-07
Hidden message.
0.3.0: 2017-07-28
Refactor normal mapping to <Plug> mapping.
Remove mapping options:
g:complete_parameter_goto_next_mode,
g:complete_parameter_mapping_goto_next,
g:complete_parameter_goto_previous_mode,
g:complete_parameter_mapping_goto_previous,
g:complete_parameter_mapping_overload_up_mode,
g:complete_parameter_mapping_overload_up,
g:complete_parameter_mapping_overload_down_mode,
g:complete_parameter_mapping_overload_down,
g:complete_parameter_mapping_complete,
g:complete_parameter_failed_insert,
g:complete_parameter_mapping_complete_for_ft
Add mapping.
<Plug>(complete_parameter#goto_next_parameter),
<Plug>(complete_parameter#goto_previous_parameter),
<Plug>(complete_parameter#overload_up),
<Plug>(complete_parameter#overload_down)
Add options: g:complete_parameter_use_ultisnips_mappings
Fix parser bug.
0.2.3: 2017-07-22
Change `<m-n>`/`<m-p>` to `<c-j>`/`<c-k>` and compatible with ultisnips.
Disable normal mapping.
Fix parser bug.
0.2.2: 2017-07-07
Only jump between in the scope.
Check the value of the parser returned.
0.2.1: 2017-06-30
Fix bug.
0.2.0: 2017-06-30
Support neocomplete.
Support clang_complete.
0.1.6: 2017-06-29
Support deoplete.nvim
0.1.5: 2017-06-25
Compate with neosnippet.
0.1.4: 2017-06-23
Toggle an event CompleteParameterFailed if complete failed.
Add a variable `g:complete_parameter_last_failed_insert` to set the failed_insert.
Fixed bug, delete select text when call the jump mapping.
0.1.3: 2017-06-20
Fix the info for python function has multi lines.
0.1.2: 2017-06-17
Support typescript.
Support nvim.
Support vim7.4.774.
Parallel test.
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.
0.1.0: 2017-06-15
Support `(` select the first completion item if inserted word is equal to the first popup item.
0.0.3: 2017-06-15
Support multi called for a file.
Support cpp class template.
Fix python parser.
Add github templates.
0.0.2: 2017-06-14
Support c, cpp, rust, javascript, python.
Support overload functions.
Update screenshot.
Add shields.
0.0.1: 2017-06-12
Init version. Support golang, erlang paramater.

View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2017 tenfyzhong
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -0,0 +1,255 @@
# CompleteParameter.vim
[![Join the chat at https://gitter.im/tenfyzhong/CompleteParameter.vim](https://badges.gitter.im/tenfyzhong/CompleteParameter.vim.svg)](https://gitter.im/tenfyzhong/CompleteParameter.vim?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Build Status](https://travis-ci.org/tenfyzhong/CompleteParameter.vim.svg?branch=master)](https://travis-ci.org/tenfyzhong/CompleteParameter.vim)
[![GitHub tag](https://img.shields.io/github/tag/tenfyzhong/CompleteParameter.vim.svg)](https://github.com/tenfyzhong/CompleteParameter.vim/tags)
![Vim Version](https://img.shields.io/badge/support-Vim%207.4.774%E2%86%91or%20NVIM-yellowgreen.svg?style=flat)
[![doc](https://img.shields.io/badge/doc-%3Ah%20CompleteParameter-yellow.svg?style=flat)](https://github.com/tenfyzhong/CompleteParameter.vim/blob/develop/doc/complete_parameter.txt)
CompleteParameter is a plugin for complete function's parameters after complete
a function.
If you like this plugin, please star it.
# Screenshots
Without CompleteParameter, only insert the function name.
![ycm_only](http://wx4.sinaimg.cn/mw690/69472223gy1fhyjw7996cg20hs0a0n1b.gif)
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>`.
![ycm_with_cp](http://wx4.sinaimg.cn/mw690/69472223gy1fhyjvrjhr3g20hs0a0qby.gif)
# Features
- Complete parameters after select a complete item from the completion popup menu.
- After complete the parameters, jump to the first parameter and the select it.
- Jump to next parameter.
- Jump to previous parameter.
- Select next overload function.
- Select previous overload function.
- Select the first item in the completion popup menu.
- Echo signature when select an item. (need to `set noshowmode` or `set cmdheight=2`)
# Install
I suggest you to use a plugin manager, such vim-plug or other.
- [vim-plug][]
```viml
Plug 'tenfyzhong/CompleteParameter.vim'
```
- Manual
```
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!
```
# Usage
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.
# Minimal setting
```viml
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.**
# Mapping
### `<Plug>(complete_parameter#goto_next_parameter)`
Goto next parameter and select it.
eg:
```viml
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:
```viml
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:
```viml
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:
```viml
nmap <m-u> <Plug>(complete_parameter#overload_up)
imap <m-u> <Plug>(complete_parameter#overload_up)
smap <m-u> <Plug>(complete_parameter#overload_up)
```
# Options
### The `g:complete_parameter_log_level` option
This 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
```viml
let g:complete_parameter_log_level = 5
```
### The `g:complete_parameter_use_ultisnips_mappings` option
If this option is 1 and you use ultisnips together, it will use ultisnips mapping
to goto next or previous parameter.
default: 0
```viml
let g:complete_parameter_use_ultisnips_mapping = 0
```
### The `g:complete_parameter_echo_signature` option
It will echo signature if this option is 1. (need to `set noshowmode` or `set cmdheight=2`)
default: 1
```viml
let g:complete_parameter_echo_signature = 1
```
### The `g:complete_parameter_py_keep_value` option
It 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
```viml
let g:complete_parameter_py_keep_value = 1
```
### The `g:complete_parameter_py_remove_default` option
It 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
```viml
let g:complete_parameter_py_remove_default = 1
```
# Supported
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][] | |
## Setting for completion plugins
### `vim-racer`
```viml
let g:racer_experimental_completer = 1
```
### `tern_for_vim`
```viml
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`
```viml
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*::'
```
# FAQ
### Can't work with plugin auto-pairs use the default mapping `(`
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.
```viml
let g:AutoPairs = {'[':']', '{':'}',"'":"'",'"':'"', '`':'`'}
inoremap <buffer><silent> ) <C-R>=AutoPairsInsert(')')<CR>
```
### Can't jump to next parameter
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.
### How to accept the selected function but not parameters
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.
### The mapping `<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
Contributions and pull requests are welcome.
# Thanks
- [johnzeng](https://github.com/johnzeng), support erlang
# LICENSE
MIT License Copyright (c) 2017 tenfyzhong
[vim-plug]: https://github.com/junegunn/vim-plug
[YouCompleteMe]: https://github.com/Valloric/YouCompleteMe
[deoplete]: https://github.com/Shougo/deoplete.nvim
[neocomplete]: https://github.com/Shougo/neocomplete.vim
[clang_complete]: https://github.com/Rip-Rip/clang_complete
[deoplete-clang]: https://github.com/zchee/deoplete-clang
[nvim-typescript]: https://github.com/mhartington/nvim-typescript
[deoplete-rust]: https://github.com/sebastianmarkow/deoplete-rust
[jedi-vim]: https://github.com/davidhalter/jedi-vim
[deoplete-ternjs]: https://github.com/carlitux/deoplete-ternjs
[deoplete-jedi]: https://github.com/zchee/deoplete-jedi
[vim-erlang-omnicomplete]: https://github.com/johnzeng/vim-erlang-omnicomplete
[vim-go]: https://github.com/fatih/vim-go
[vim-racer]: https://github.com/racer-rust/vim-racer
[tern_for_vim]: https://github.com/ternjs/tern_for_vim
[tsuquyomi]: https://github.com/Quramy/tsuquyomi

View File

@ -0,0 +1,23 @@
"==============================================================
" file: compatible_with_ultisnips.vim
" brief:
" VIM Version: 8.0
" author: tenfyzhong
" email: tenfy@tenfy.cn
" created: 2017-07-14 22:08:37
"==============================================================
if !exists(':UltiSnipsEdit') || get(g:, 'complete_parameter_use_ultisnips_mappings', 0) == 0
finish
endif
if g:UltiSnipsExpandTrigger == g:UltiSnipsJumpForwardTrigger
exec printf('inoremap <silent> %s <c-r>=UltiSnips#ExpandSnippetOrJump()<cr><c-r>=cmp#ultisnips#ExpandTrigger()<cr>', g:UltiSnipsExpandTrigger)
exec printf('snoremap <silent> %s <ESC>:call UltiSnips#ExpandSnippetOrJump()<cr><ESC>:call cmp#ultisnips#ExpandTrigger()<cr>', g:UltiSnipsExpandTrigger)
else
exec printf('inoremap <silent> %s <c-r>=UltiSnips#JumpForwards()<cr><c-r>=cmp#ultisnips#JumpForward()<cr>', g:UltiSnipsJumpForwardTrigger)
exec printf('snoremap <silent> %s <ESC>:call UltiSnips#JumpForwards()<cr><ESC>:call cmp#ultisnips#JumpForward()<cr>', g:UltiSnipsJumpForwardTrigger)
endif
exec printf("inoremap <silent> %s <c-r>=UltiSnips#JumpBackwards()<cr><c-r>=cmp#ultisnips#JumpBackward()<cr>", g:UltiSnipsJumpBackwardTrigger)
exec printf("snoremap <silent> %s <ESC>:call UltiSnips#JumpBackwards()<cr><ESC>:call cmp#ultisnips#JumpBackward()<cr>", g:UltiSnipsJumpBackwardTrigger)

View File

@ -0,0 +1,858 @@
"==============================================================
" file: complete_parameter.vim
" brief:
" VIM Version: 8.0
" author: tenfyzhong
" email: tenfy@tenfy.cn
" created: 2017-06-07 20:29:10
"==============================================================
let s:complete_parameter = {'index': 0, 'items': [], 'complete_pos': [], 'success': 0, 'echos': []}
let g:complete_parameter_last_failed_insert = ''
let s:log_index = 0
function! cmp#init() abort "{{{
runtime! cm_parser/*.vim
" ultisnips will remove all smaps, this will without this plugin
let g:UltiSnipsMappingsToIgnore = get(g:, 'UltiSnipsMappingsToIgnore', []) + ["complete_parameter"]
" neosnippet will remove all smaps
let g:neosnippet#disable_select_mode_mappings = 0
" 4 error
" 2 error + debug
" 1 erro + debug + trace
let g:complete_parameter_log_level = get(g:, 'complete_parameter_log_level', 5)
let g:complete_parameter_use_ultisnips_mappings = get(g:, 'complete_parameter_use_ultisnips_mappings', 0)
endfunction "}}}
function! cmp#default_echos(completed_item)
return []
endfunction
let s:ftfunc_prefix = 'cm_parser#'
let s:ftfunc = {'ft': ''}
function! cmp#new_ftfunc(filetype) abort "{{{
if empty(a:filetype)
throw 'filetype is empty'
endif
let ftfunc = deepcopy(s:ftfunc)
let ftfunc['ft'] = a:filetype
try
let ftfunc['parameters'] = function(s:ftfunc_prefix . a:filetype .'#parameters')
let ftfunc['parameter_delim'] = function(s:ftfunc_prefix . a:filetype . '#parameter_delim')
let ftfunc['parameter_begin'] = function(s:ftfunc_prefix. a:filetype . '#parameter_begin')
let ftfunc['parameter_end'] = function(s:ftfunc_prefix . a:filetype . '#parameter_end')
if exists('*'.s:ftfunc_prefix.a:filetype.'#echos')
let ftfunc['echos'] = function(s:ftfunc_prefix.a:filetype.'#echos')
else
let ftfunc['echos'] = function('cmp#default_echos')
endif
catch /^E700/
throw 'the function should be defined: ' . v:exception
endtry
return ftfunc
endfunction "}}}
function! s:filetype_func_exist(filetype) abort "{{{
let filetype_func_prefix = s:ftfunc_prefix.a:filetype.'#'
let parameters_func_name = filetype_func_prefix.'parameters'
let parameter_delim_func_name = filetype_func_prefix.'parameter_delim'
let parameter_begin_func_name = filetype_func_prefix.'parameter_begin'
let parameter_end_func_name = filetype_func_prefix.'parameter_end'
if !exists('*'.parameters_func_name) ||
\!exists('*'.parameter_delim_func_name) ||
\!exists('*'.parameter_begin_func_name) ||
\!exists('*'.parameter_end_func_name)
return 0
endif
return 1
endfunction "}}}
function! cmp#filetype_func_check(ftfunc) abort "{{{
if !<SID>filetype_func_exist(a:ftfunc['ft'])
return 0
endif
" let parameters = a:ftfunc.parameters(v:completed_item)
" if type(parameters) != 3
" return 0
" endif
if !exists('*'.string(a:ftfunc.parameter_delim))
return 0
endif
let delim = a:ftfunc.parameter_delim()
if type(delim) != 1 || empty(delim)
return 0
endif
if !exists('*'.string(a:ftfunc.parameter_begin))
return 0
endif
let begin = a:ftfunc.parameter_begin()
if type(begin) != 1 || empty(begin)
return 0
endif
if !exists('*'.string(a:ftfunc.parameter_end))
return 0
endif
let end = a:ftfunc.parameter_end()
if type(end) != 1 || empty(end)
return 0
endif
return 1
endfunction "}}}
" check v:completed_item is empty or not
function! s:empty_completed_item() abort "{{{
let completed_item = v:completed_item
if empty(completed_item)
return 1
endif
let menu = get(completed_item, 'menu', '')
let info = get(completed_item, 'info', '')
let kind = get(completed_item, 'kind', '')
let abbr = get(completed_item, 'abbr', '')
return empty(menu) && empty(info) && empty(kind) && empty(abbr)
endfunction "}}}
" select an item if need, and the check need to revert or not
" else call the complete function
function! cmp#pre_complete(failed_insert) abort "{{{
let s:log_index = <SID>timenow_ms()
if !pumvisible()
return <SID>failed_event(a:failed_insert)
endif
let completed_word = get(v:completed_item, 'word', '')
if <SID>empty_completed_item() && pumvisible()
let feed = printf("\<C-r>=cmp#check_revert_select('%s', '%s')\<ENTER>", a:failed_insert, completed_word)
call feedkeys(feed, 'n')
return "\<C-n>"
else
return cmp#complete(a:failed_insert)
endif
endfunction "}}}
function! cmp#default_failed_insert(failed_insert) "{{{
if a:failed_insert =~# '()$'
return "\<LEFT>"
else
return ''
endif
endfunction "}}}
function! s:failed_event(failed_insert) abort "{{{ return the text to insert and toggle event
let keys = ''
if exists('*CompleteParameterFailed')
let keys = CompleteParameterFailed(a:failed_insert)
else
let keys = cmp#default_failed_insert(a:failed_insert)
endif
let content = getline(line('.'))
let parameter = a:failed_insert
let pos = col('.') - 2
if pos > 0
let posEnd = pos + len(parameter) - 1
if content[pos : posEnd] !=# parameter &&
\content[pos] ==# parameter[0]
let parameter = substitute(parameter, '\m.\(.*\)', '\1', '')
endif
endif
let keys = parameter . keys
call <SID>trace_log(keys)
return keys
endfunction "}}}
" if the select item is not match with completed_word, the revert
" else call the complete function
function! cmp#check_revert_select(failed_insert, completed_word) abort "{{{
let select_complete_word = get(v:completed_item, 'word', '')
call <SID>trace_log('s:completed_word: ' . a:completed_word)
call <SID>trace_log('select_complete_word: ' . select_complete_word)
redraw!
if select_complete_word !=# a:completed_word
return <SID>failed_event("\<C-p>".a:failed_insert)
else
let keys = cmp#complete(a:failed_insert)
return keys
endif
endfunction "}}}
function! cmp#check_parameter_return(parameter, parameter_begin, parameter_end) abort "{{{
if len(a:parameter) < 2
return 0
endif
" echom printf('mb, begin: %s, p[0]: %s, result: %d', a:parameter_begin, a:parameter[0], match(a:parameter_begin, a:parameter[0]) != -1)
" echom printf('me, end: %s, p[-1]: %s, result: %d', a:parameter_end, a:parameter[-1], match(a:parameter_end, a:parameter[len(a:parameter)-1]) != -1)
return match(a:parameter_begin, a:parameter[0]) != -1 &&
\match(a:parameter_end, a:parameter[len(a:parameter)-1]) != -1
endfunction "}}}
function! cmp#complete(failed_insert) abort "{{{
call <SID>trace_log(string(v:completed_item))
if <SID>empty_completed_item()
call <SID>debug_log('v:completed_item is empty')
return <SID>failed_event(a:failed_insert)
endif
let filetype = &ft
if empty(filetype)
call <SID>debug_log('filetype is empty')
return <SID>failed_event(a:failed_insert)
endif
try
let ftfunc = cmp#new_ftfunc(filetype)
catch
call <SID>debug_log('new_ftfunc failed. '.string(v:exception))
return <SID>failed_event(a:failed_insert)
endtry
if !cmp#filetype_func_check(ftfunc)
call <SID>error_log('ftfunc check failed')
return <SID>failed_event(a:failed_insert)
endif
" example: the complete func like this`func Hello(param1 int, param2 string) int`
" the parsed must be a list and the element of the list is a dictional,
" the dictional must have the below keys
" text: the text to be complete -> `(param1, param2)`
" delim: the delim of parameters -> `,`
" prefix: the begin of text -> `(`
" suffix: the end of the text -> `)`
let parseds = ftfunc.parameters(v:completed_item)
call <SID>debug_log(string(parseds))
if type(parseds) != 3
call <SID>error_log('return type error')
return <SID>failed_event(a:failed_insert)
endif
let parameter_begin = ftfunc.parameter_begin()
let parameter_end = ftfunc.parameter_end()
if empty(parseds) || len(parseds[0]) < 2 || !cmp#check_parameter_return(parseds[0], parameter_begin, parameter_end)
call <SID>debug_log("parseds is empty")
return <SID>failed_event(a:failed_insert)
endif
let s:complete_parameter['index'] = 0
let s:complete_parameter['items'] = parseds
let s:complete_parameter['complete_pos'] = [line('.'), col('.')]
let col = s:complete_parameter['complete_pos'][1]
let s:complete_parameter['success'] = 1
if get(g:, 'complete_parameter_echo_signature', 1)
let s:complete_parameter['echos'] = ftfunc.echos(v:completed_item)
endif
" if the first char of parameter was inserted, remove it from the parameter
let content = getline(line('.'))
let parameter = s:complete_parameter['items'][0]
if col > 1
if content[col-2] ==# parameter[0]
let parameter = substitute(parameter, '\m.\(.*\)', '\1', '')
let s:complete_parameter['complete_pos'][1] = col - 1
endif
endif
" must be insert mode
" the cursor is in the last char+1,col('$')
" we need the pass the last char col, so col('.')-1
return cmp#goto_first_param(parameter, content, col('.')-1)
endfunction "}}}
function! cmp#goto_first_param(parameter, content, current_col) abort "{{{
let old_ei = &ei
set ei=InsertLeave,InsertEnter,TextChanged
if s:complete_parameter['success']
call <SID>trace_log(printf('content:[%s] current_col:%d, left:[%s], right:[%s]', a:content, a:current_col, a:content[:a:current_col-1], a:content[a:current_col:]))
let content = a:content[:a:current_col-1] . a:parameter . a:content[a:current_col:]
call <SID>trace_log("content: " . content)
call <SID>trace_log("current_col: " . a:current_col)
" the current_col is no in the `()`
" show we need to add 1
let keys = cmp#goto_next_param_keys(1, content, a:current_col+1)
let keys = printf("%s\<ESC>%s", a:parameter, keys)
call <SID>trace_log("keys: ". keys)
let index = s:complete_parameter['index']
if len(s:complete_parameter['echos']) > index && s:complete_parameter['echos'][index] !=# ''
echon s:complete_parameter['echos'][index]
endif
let &ei=old_ei
return keys
else
let &ei=old_ei
return a:parameter
endif
endfunction "}}}
function! cmp#goto_next_param_keys(forward, content, current_col) abort "{{{
let filetype = &ft
if empty(filetype)
call <SID>debug_log('filetype is empty')
return ''
endif
try
let ftfunc = cmp#new_ftfunc(filetype)
catch
call <SID>debug_log('new ftfunc failed')
return ''
endtry
if !cmp#filetype_func_check(ftfunc)
return ''
endif
let step = a:forward ? 1 : -1
let delim = ftfunc.parameter_delim()
let border_begin = a:forward ? ftfunc.parameter_begin() : ftfunc.parameter_end()
let border_end = a:forward ? ftfunc.parameter_end() : ftfunc.parameter_begin()
" if in the insert mode
" go back to the first none space
" this can select the parameter after cursor
let pos = a:current_col-1
let scope_end = step > 0 ? -1 : len(a:content)
if mode() ==# 'i'
while pos != scope_end &&
\(a:content[pos-1] =~# '['.delim.border_begin.']' ||
\ a:content[pos-1] ==# ' ')
let pos -= 1
if a:content[pos] =~# '['.delim.border_begin.']'
break
endif
endwhile
endif
let [word_begin, word_end] = cmp#parameter_position(a:content, pos+1, delim, border_begin, border_end, step)
call <SID>trace_log(printf('content:[%s],current_col:%d,word_begin:%d,word_end:%d', a:content, a:current_col, word_begin, word_end))
if word_begin == 0 && word_end == 0
call <SID>debug_log('word_begin and word_end is 0')
return ''
endif
let word_len = word_end - word_begin
call <SID>trace_log('word_len:'.word_len)
let keys = printf("\<ESC>0%dl", word_begin-2)
if word_len == 0
if a:forward
return keys . "a\<RIGHT>"
endif
else
let keys .= "lv"
if &selection ==# 'exclusive'
let right_len = word_len
else
let right_len = word_len - 1
endif
if right_len > 0
let keys .= right_len
let keys .= "l"
endif
let keys .= "\<C-G>"
return keys
endif
return ''
endfunction "}}}
function! cmp#goto_next_param(forward) abort "{{{
let s:log_index = <sid>timenow_ms()
let filetype = &ft
if empty(filetype)
call <SID>debug_log('filetype is empty')
return ''
endif
try
let ftfunc = cmp#new_ftfunc(filetype)
catch
call <SID>debug_log('new ftfunc failed')
return ''
endtry
if !cmp#filetype_func_check(ftfunc)
return ''
endif
let step = a:forward ? 1 : -1
let border_end = a:forward ? ftfunc.parameter_end() : ftfunc.parameter_begin()
let lnum = line('.')
let content = getline(lnum)
let current_col = col('.')
let pos = current_col - 1
let parameter_delim = ftfunc.parameter_delim()
if !a:forward && &selection==#'exclusive' &&
\(match(parameter_delim, content[pos])!=-1 ||
\ match(ftfunc.parameter_end(), content[pos])!=-1)
let current_col -= 1
let pos -= 1
endif
" if the selected is an object and the cursor char is an border_end
" go back to border_begin and it can select the item in the object.
if mode() == 'n' && match(border_end, content[pos]) != -1
normal %
let current_col = col('.')
endif
let keys = cmp#goto_next_param_keys(a:forward, content, current_col)
call feedkeys(keys, 'n')
return ''
endfunction "}}}
" items: all overload complete function parameters
" current_line: current line content
" complete_pos: the pos where called complete
" forward: down or up
" [success, item, next_index, old_item_len]
function! cmp#next_overload_content(items, current_index, current_line, complete_pos, forward) abort "{{{
if len(a:items) <= 1 ||
\a:current_index >= len(a:items) ||
\empty(a:current_line) ||
\len(a:current_line) < a:complete_pos[1]
return [0]
endif
let current_overload_len = len(a:items[a:current_index])
let pos = a:complete_pos[1] - 1
let pos_end = pos+current_overload_len-1
let content = a:current_line[ pos : pos_end ]
if content !=# a:items[a:current_index]
return [0]
endif
let overload_len = len(a:items)
if a:forward
let next_index = (a:current_index + 1) % overload_len
else
let next_index = (a:current_index+overload_len-1)%overload_len
endif
return [1, a:items[next_index], next_index, len(a:items[a:current_index])]
endfunction "}}}
function! s:timenow_us()
let t = reltime()
return t[0] * 1000000 + t[1]
endfunction
function! s:timenow_ms()
return <SID>timenow_us()
endfunction
function! cmp#overload_next(forward) abort "{{{
let s:log_index = <SID>timenow_ms()
let overload_len = len(s:complete_parameter['items'])
if overload_len <= 1
return
endif
let complete_pos = s:complete_parameter['complete_pos']
let current_line = line('.')
let current_col = col('.')
" if no in the complete content
" then return
if current_line != complete_pos[0] || current_col < complete_pos[1]
call <SID>trace_log('no more overload')
return
endif
let current_index = s:complete_parameter['index']
let current_line = getline(current_line)
let result = cmp#next_overload_content(
\s:complete_parameter['items'],
\current_index,
\current_line,
\s:complete_parameter['complete_pos'],
\a:forward)
if result[0] == 0
call <SID>debug_log('get overload content failed')
return
endif
let current_overload_len = result[3]
call cursor(complete_pos[0], complete_pos[1])
call <sid>trace_log(printf('pos: %d %d', complete_pos[0], complete_pos[1]))
exec 'normal! d'.current_overload_len.'l'
let next_content = result[1]
let s:complete_parameter['index'] = result[2]
let s:complete_parameter['success'] = 1
let content = getline(line('.'))
let current_col = col('.')
let insert_method = 'a'
if current_col != col('$')-1
" if no the last char
" the cursor in the last complete char+1
" we need to -1
let current_col -= 1
let insert_method = 'i'
endif
let ret = insert_method.cmp#goto_first_param(next_content, content, current_col)
call <SID>trace_log(ret)
call feedkeys(ret, 'n')
endfunction "}}}
let s:stack = {'data':[]}
function! s:new_stack() abort "{{{
return deepcopy(s:stack)
endfunction "}}}
function! s:stack.push(e) abort dict "{{{
call add(self.data, a:e)
endfunction "}}}
function! s:stack.len() abort dict "{{{
return len(self.data)
endfunction "}}}
function! s:stack.empty() abort dict "{{{
return self.len() == 0
endfunction "}}}
function! s:stack.top() abort dict "{{{
if self.empty()
throw "stack is empty"
endif
return self.data[-1]
endfunction "}}}
function! s:stack.pop() abort dict "{{{
if self.empty()
throw "stack is empty"
endif
call remove(self.data, -1)
endfunction "}}}
function! s:stack.str() abort dict "{{{
let str = 'stack size:'.self.len()
for d in self.data
let str .= "\n"
let str .= 'stack elem:'.d
endfor
return str
endfunction "}}}
function! s:in_scope(content, pos, border, step, end) abort "{{{
" echom printf('content: %s, pos: %d, border: %s, step: %d, end: %d', a:content, a:pos, a:border, a:step, a:end)
let i = a:pos
while i != a:end
if a:content[i] =~# '\m['.a:border.']'
return 1
endif
let i += a:step
endwhile
return 0
endfunction "}}}
function! cmp#jumpable(forward) abort "{{{ can jump to next parameter or not
let filetype = &ft
try
let ftfunc = cmp#new_ftfunc(filetype)
catch
call <SID>debug_log('new ftfunc failed')
return 0
endtry
if !cmp#filetype_func_check(ftfunc)
call <SID>debug_log('func check failed')
return 0
endif
let delim = ftfunc.parameter_delim()
let border = a:forward > 0 ? ftfunc.parameter_begin() : ftfunc.parameter_end()
let step = a:forward > 0 ? -1 : 1
let lnum = line('.')
let content = getline(lnum)
let current_pos = col('.') - 1
let end = a:forward > 0 ? -1 : len(content)
return <SID>in_scope(content, current_pos, border, step, end)
endfunction "}}}
" content: string, the content to parse
" current_col: int, current col
" delim: string, split the paramter letter
" return: [int, int] begin_col, end_col
"
" col: base 1
" pos: base 0
function! cmp#parameter_position(content, current_col, delim, border_begin, border_end, step) abort "{{{
"{{{2
if empty(a:content) ||
\a:current_col==0 ||
\empty(a:delim) ||
\empty(a:border_begin) ||
\empty(a:border_end) ||
\len(a:border_begin) != len(a:border_end) ||
\a:step==0
call <SID>debug_log('parameter_position param error')
return [0, 0]
endif "}}}2
let step = a:step > 0 ? 1 : -1
let current_pos = a:current_col - 1
let content_len = len(a:content)
let end = a:step > 0 ? content_len : -1
if current_pos >= content_len
let current_pos = content_len-1
endif
" check current pos is in the scope or not
let scope_end = step > 0 ? -1 : content_len
if !<SID>in_scope(a:content, current_pos, a:border_begin, -step, scope_end)
call <SID>trace_log(printf("no in scope, content: %s, current_pos: %d, a:border_begin: %s, step: %d, scope_end: %d", a:content, current_pos, a:border_begin, -step, scope_end))
retur [0, 0]
endif
let stack = <SID>new_stack()
let pos = current_pos
let border_matcher = {}
let border_begin_chars = split(a:border_begin, '\zs')
let border_end_chars = split(a:border_end, '\zs')
let i = 0
while i < len(border_end_chars)
let border_matcher[border_begin_chars[i]] = '\m['.a:delim.border_end_chars[i].']'
let i += 1
endwhile
" let border_matcher[a:border_begin] = '\m['.a:delim.a:border_end.']'
let border_matcher[a:delim] = '\m['.a:delim.a:border_end.']'
let border_matcher['"'] = '"'
let border_matcher["'"] = "'"
let border_matcher["`"] = "`"
let begin_pos = 0
let end_pos = 0
" check has previous quote
let quote_test_content_pos = pos
if a:content[quote_test_content_pos] =~# '\m["''`]'
let quote_test_content_pos -= step
endif
let quote_test_content = a:content[:quote_test_content_pos]
let quote_test_content = substitute(quote_test_content, '\m\\.', '', 'g')
let quote_test_content = substitute(quote_test_content, '\m[^"''`]', '', 'g')
let quotes = split(quote_test_content, '\zs')
for quote in quotes
if stack.empty()
call stack.push(quote)
elseif border_matcher[stack.top()] ==# quote
call stack.pop()
endif
endfor
while pos != end "{{{2
if step < 0
if pos + step != end && a:content[pos+step] == '\'
let pos += 2*step
continue
endif
endif
" if top of stack is quote and current letter is not a quote
" the letter should be ignore
if !stack.empty() && stack.top() =~# '\m["`'']' && a:content[pos] !~# '\m["`''\\]'
let pos += step
continue
endif
if a:content[pos] ==# '"' || a:content[pos] ==# "'" || a:content[pos] ==# '`'
if stack.empty() || border_matcher[stack.top()] !=# a:content[pos]
call stack.push(a:content[pos])
else
call stack.pop()
endif
elseif a:content[pos] ==# '\'
let pos += step
elseif a:content[pos] ==# '='
if step > 0
if stack.len() > 1
" if stack more than 1, current maybe in the nest scope, ignore it
let pos += step
continue
endif
let pos += step
let pos = <SID>find_first_not_space(a:content, pos, end, step)
if pos == end
break
endif
let begin_pos = pos
if stack.len() == 0
" let = as a delim, it's the next begining
call stack.push(a:delim[0])
endif
continue
else
" backword
" if stack is empty, we need to find the first begin or delim
" if stack more than 1, current maybe in the nest scope, ignore it
if stack.len() != 1
let pos += step
continue
else
" if stack len is 1, and current pos must be want to select
break
endif
endif
elseif stridx(a:border_begin, a:content[pos]) != -1
if a:content[pos] ==# '>' && step < 0
" check if there are is a '<' or not
let tmppos = pos + step
while tmppos >= 0 && a:content[tmppos] !=# '<'
let tmppos += step
endwhile
if tmppos < 0
let pos += step
continue
endif
endif
call stack.push(a:content[pos])
if stack.len() == 1
" begin
let pos += step
let pos = <SID>find_first_not_space(a:content, pos, end, step)
if pos == end
break
endif
let begin_pos = pos
" no need to step forward
" goto the beginning of the loop
continue
endif
elseif a:content[pos] ==# a:delim
if stack.empty()
call stack.push(a:content[pos])
let pos += step
let pos = <SID>find_first_not_space(a:content, pos, end, step)
if pos == end
break
endif
let begin_pos = pos
" no need to step forward
" goto the beginning of the loop
continue
elseif stack.len() == 1 && a:content[pos] =~# border_matcher[stack.top()]
call stack.pop()
if stack.empty()
" match delim
break
endif
endif
elseif stridx(a:border_end, a:content[pos]) != -1
if a:content[pos] ==# '<' && step > 0
" check if there are is a '>' or not
let tmppos = pos + step
while tmppos < content_len && a:content[tmppos] !=# '>'
let tmppos += step
endwhile
if tmppos >= content_len
let pos += step
continue
endif
endif
if stack.empty()
let begin_pos = pos
let end_pos = pos
else
if a:content[pos] =~# border_matcher[stack.top()]
" border match, then pop
call stack.pop()
if stack.empty()
" match delim
break
endif
endif
endif
endif
let pos += step
endwhile "}}}2
if pos == end
if begin_pos != 0 && end_pos != 0
return [begin_pos+1,end_pos+1]
else
return [0, 0]
endif
endif
if begin_pos != pos
let pos -= step
" find previous no space
while pos != begin_pos && a:content[pos] =~# '\s'
let pos -= step
endwhile
endif
let end_pos = pos
if begin_pos == end_pos && stridx(a:border_end, a:content[end_pos]) != -1
return [begin_pos+1, end_pos+1]
endif
if end_pos < begin_pos
let [begin_pos, end_pos] = [end_pos, begin_pos]
endif
return [begin_pos+1, end_pos+2]
endfunction "}}}
function! s:find_first_not_space(content, pos, end, step) abort "{{{
let pos = a:pos
if pos == -1 ||
\pos==len(a:content)
return pos == a:end
endif
if a:step == 0
throw 'step is 0'
endif
while pos != a:end && a:content[pos] =~# '\s'
let pos += a:step
endwhile
return pos
endfunction "}}}
function! s:log(level, msg) abort "{{{
echom printf("[CompleteParameter][%s][%s][%d] %s", strftime("%T"), a:level, s:log_index, a:msg)
endfunction "}}}
function! s:error_log(msg) abort "{{{
if g:complete_parameter_log_level <= 4
echohl ErrorMsg
call <SID>log('ERROR', a:msg)
echohl None
endif
endfunction "}}}
function! s:debug_log(msg) abort "{{{
if g:complete_parameter_log_level <= 2
call <SID>log('DEBUG', a:msg)
endif
endfunction "}}}
function! s:trace_log(msg) abort "{{{
if g:complete_parameter_log_level <= 1
call <SID>log('TRACE', a:msg)
endif
endfunction "}}}

View File

@ -0,0 +1,33 @@
"==============================================================
" file: ultisnips.vim
" brief:
" VIM Version: 8.0
" author: zhongtenghui
" email: zhongtenghui@gf.com.cn
" created: 2017-07-28 14:37:19
"==============================================================
function! s:wrap_next(check_val, forward) abort
if get(g:, a:check_val, 0) == 0
return cmp#goto_next_param(a:forward)
else
exec printf('let g:%s=0', a:check_val)
if getchar(1) == 0
call feedkeys('a', 'n')
endif
return ''
endif
endfunction
function! cmp#ultisnips#ExpandTrigger() abort
return <SID>wrap_next('ulti_expand_or_jump_res', 1)
endfunction
function! cmp#ultisnips#JumpForward() abort
return <SID>wrap_next('ulti_jump_forwards_res', 1)
endfunction
function! cmp#ultisnips#JumpBackward() abort
return <SID>wrap_next('ulti_jump_backwards_res', 0)
endfunction

View File

@ -0,0 +1,18 @@
"==============================================================
" file: complete_parameter.vim
" brief:
" VIM Version: 8.0
" author: zhongtenghui
" email: zhongtenghui@gf.com.cn
" created: 2017-08-10 09:37:46
"==============================================================
" deprecated
function! complete_parameter#pre_complete(failed_inserted) "{{{
return cmp#pre_complete(a:failed_inserted)
endfunction "}}}
" deprecated
function! complete_parameter#jumpable(forward) "{{{
return cmp#jumpable(a:forward)
endfunction "}}}

View File

@ -0,0 +1,24 @@
#!/bin/bash -
set -e
if [[ "$VIM_NAME" == 'nvim' ]]; then
if [[ "$TRAVIS_OS_NAME" == 'osx' ]]; then
curl -LO https://github.com/neovim/neovim/releases/download/nightly/nvim-macos.tar.gz
tar xzf nvim-macos.tar.gz
else
sudo add-apt-repository ppa:neovim-ppa/unstable -y
sudo apt-get update -y
sudo apt-get install neovim -y
fi
else
wget https://codeload.github.com/vim/vim/tar.gz/v7.4.774
tar xzf v7.4.774
cd vim-7.4.774
./configure --prefix="$HOME/vim" \
--enable-fail-if-missing \
--with-features=huge
make -j 2
make install
fi

View File

@ -0,0 +1,16 @@
#!/bin/bash -
set -e
if [ $# -ne 1 ]; then
exit 1
fi
$1 -Nu <(cat << VIMRC
filetype off
set rtp+=vader.vim
set rtp+=.
runtime! cm_parser/*.vim
filetype plugin indent on
syntax enable
VIMRC) -c 'Vader! vader/*' > /dev/null

View File

@ -0,0 +1,85 @@
"==============================================================
" file: c.vim
" brief:
" VIM Version: 8.0
" author: tenfyzhong
" email: tenfy@tenfy.cn
" created: 2017-06-13 19:52:45
"==============================================================
" ycm macro
" {'word': 'CMP', 'menu': '', 'info': ' CMP( a, b )^@', 'kind': 'm', 'abbr': 'CMP( a, b )'}
function! s:parse_macro(word, info)
let param = substitute(a:info, '\m\s*'.a:word.'\(([^()]*)\).*', '\1', 'g')
let param = substitute(param, '\m( *', '(', 'g')
let param = substitute(param, '\m *)', ')', 'g')
return [param]
endfunction
function! s:parse(abbr) "{{{
let param = substitute(a:abbr, '\m\%(\w\+\s*\)\?\w\+\((.*)\).*', '\1', '') " get parameters
let param = substitute(param, '\m\([(,]\)\s*\%(\w\+\s\+\)*\s*\(\w\+\s*\)\s*\(\**\)\(\s*[,)]\)', '\1\2 \3\2\4', 'g')
let param = substitute(param, '\m\s*\%(\w\+\s\+\)*\s*\**\s*\(\%(\w\+\)\s*[,)]\)', '\1', 'g')
let param = substitute(param, '\s\+', '', 'g')
let param = substitute(param, '\m,', ', ', 'g')
return [param]
endfunction "}}}
" deoplete
" {'word': 'time', 'menu': '[clang] ', 'info': 'time(time_t *)', 'kind': 'f time_t', 'abbr': 'time(time_t *)'}
" clang_complete
" {'word': 'timevalsub', 'menu': 'void timevalsub(struct timeval *t1, struct timeval *t2)', 'info': 'timevalsub(struct timeval *t1, struct timeval *t2)', 'kind': 'f', 'abbr': 'timevalsub'}
function! cm_parser#c#parameters(completed_item) "{{{
let kind = get(a:completed_item, 'kind', '')
let l:abbr = get(a:completed_item, 'abbr', '')
let word = get(a:completed_item, 'word', '')
let l:menu = get(a:completed_item, 'menu', '')
let info = get(a:completed_item, 'info', '')
if empty(l:abbr)
return []
endif
if kind ==# 'f' && l:abbr == word
" clang_complete
return <SID>parse(l:menu)
elseif kind ==# 'f'
" ycm
return <SID>parse(l:abbr)
elseif kind =~# '\m^f .*' && l:menu ==# '[clang] ' && !empty(word) && l:abbr =~# '\m^'.word.'(.*)'
" deoplete
return <SID>parse(l:abbr)
elseif kind ==# 'm'
return <SID>parse_macro(word, info)
endif
return []
endfunction "}}}
function! cm_parser#c#parameter_delim() "{{{
return ','
endfunction "}}}
function! cm_parser#c#parameter_begin() "{{{
return '('
endfunction "}}}
function! cm_parser#c#parameter_end() "{{{
return ')'
endfunction "}}}
function! cm_parser#c#echos(completed_item) "{{{
let kind = get(a:completed_item, 'kind', '')
let l:abbr = get(a:completed_item, 'abbr', '')
let word = get(a:completed_item, 'word', '')
let l:menu = get(a:completed_item, 'menu', '')
if kind ==# 'f' && l:abbr == word
" clang_complete
return [l:menu]
elseif kind ==# 'f'
" ycm
return [l:abbr]
elseif kind =~# '\m^f .*' && l:menu ==# '[clang] ' && !empty(word) && l:abbr =~# '\m^'.word.'(.*)'
" deoplete
return [l:abbr]
endif
return []
endfunction "}}}

View File

@ -0,0 +1,98 @@
"==============================================================
" file: cpp.vim
" brief:
" VIM Version: 8.0
" author: zhongtenghui
" email: zhongtenghui@gf.com.cn
" created: 2017-06-13 08:58:09
"==============================================================
" ycm macro
" {'word': 'CMP', 'menu': '', 'info': ' CMP( a, b )^@', 'kind': 'm', 'abbr': 'CMP( a, b )'}
function! s:parse_macro(word, info)
let param = substitute(a:info, '\m\s*'.a:word.'\(([^()]*)\).*', '\1', 'g')
let param = substitute(param, '\m( *', '(', 'g')
let param = substitute(param, '\m *)', ')', 'g')
return [param]
endfunction
" ycm
"
" deoplete
" {'word': 'erase', 'menu': '[clang] ', 'info': 'erase(const_iterator __position)', 'kind': 'f iterator', 'abbr': 'erase(const_iterator __position)'}
function! s:parse_function(word, info) "{{{
let result = []
let decls = split(a:info, "\n")
for decl in decls
if empty(decl) || decl =~# '^\s*'.a:word.'\s*$'
continue
endif
let param = substitute(decl, '\m^.*\<'.a:word.'\((.*)\).*', '\1', '')
" remove <.*>
while param =~# '<.*>'
let param = substitute(param, '\m<[^<>]*>', '', 'g')
endwhile
let param = substitute(param, '\m=\s*\w*\%(([^)]*)\)\?\s*', '', 'g')
let param = substitute(param, '\m\%(\s*[^(,)]*\s\)*\s*[&*]\?\s*\(\%(\w\+\)\|\%([*&]\)\)\s*\([,)]\)', '\1\2', 'g')
let param = substitute(param, ',', ', ', 'g')
call add(result, param)
endfor
return result
endfunction "}}}
" ycm
"
" deoplete
" {'word': 'vector', 'menu': '[clang] ', 'info': 'vector<class _Tp>', 'kind': 'p ', 'abbr' : 'vector<class _Tp>'}
function! s:parse_class(word, info) "{{{
let result = []
let decls = split(a:info, "\n")
for decl in decls
if empty(decl) || decl =~# '^\s*'.a:word.'\s*$'
continue
endif
let param = substitute(decl, '\m^.*\<'.a:word.'\(<.*>\).*', '\1', '')
let param = substitute(param, '\m\%(\w\+\)\?\s*\(\w\+\s*[,>]\)', '\1', 'g')
call add(result, param)
endfor
return result
endfunction "}}}
function! cm_parser#cpp#parameters(completed_item) "{{{
let kind = get(a:completed_item, 'kind', '')
let word = get(a:completed_item, 'word', '')
let info = get(a:completed_item, 'info', '')
let l:menu = get(a:completed_item, 'menu', '')
if kind ==# 'f'
return <SID>parse_function(word, info)
elseif kind ==# 'c'
return <SID>parse_class(word, info)
elseif kind =~# '\m^f\s.\+' && l:menu ==# '[clang] '
return <SID>parse_function(word, info)
elseif kind ==# 'p ' && !empty(word) && info =~# '\m^'.word.'<.*>'
return <SID>parse_class(word, info)
elseif kind ==# 'm'
return <SID>parse_macro(word, info)
else
return []
endif
endfunction "}}}
function! cm_parser#cpp#parameter_delim() "{{{
return ','
endfunction "}}}
function! cm_parser#cpp#parameter_begin() "{{{
return '(<'
endfunction "}}}
function! cm_parser#cpp#parameter_end() "{{{
return ')>'
endfunction "}}}
function! cm_parser#cpp#echos(completed_item) "{{{
let info = get(a:completed_item, 'info', '')
let decls = split(info, "\n")
return decls
endfunction "}}}

View File

@ -0,0 +1,26 @@
"==============================================================
" file: go.vim
" brief:
" VIM Version: 8.0
" author: tenfyzhong
" email: tenfy@tenfy.cn
" created: 2017-06-10 09:59:22
"==============================================================
function! cm_parser#erlang#parameters(completed_item) "{{{
let info = a:completed_item['info']
let list = matchlist(info, '\m\w\+\((.*)\).*->.*')
return len(list) < 2 ? [] : [list[1]]
endfunction "}}}
function! cm_parser#erlang#parameter_delim() "{{{
return ','
endfunction "}}}
function! cm_parser#erlang#parameter_begin() "{{{
return '('
endfunction "}}}
function! cm_parser#erlang#parameter_end() "{{{
return ')'
endfunction "}}}

View File

@ -0,0 +1,66 @@
"==============================================================
" file: go.vim
" brief:
" VIM Version: 8.0
" author: tenfyzhong
" email: tenfy@tenfy.cn
" created: 2017-06-10 09:59:22
"==============================================================
" youcompleteme
" {'word': 'Scan', 'menu': 'func(a ...interface{}) (n int, err error)', 'info': 'Scan func(a ...interface{}) (n int, err error) func', 'kind': 'f', 'abbr': 'Scan'}
" completor
" {'word': 'Scanf', 'menu': 'func(format string, a ...interface{}) (n int, err error)', 'info': '', 'kind': '', 'abbr': ''}
" neocomplete
" {'word': 'Scan(', 'menu': '[O] ', 'info': 'func Scan(a ...interface{}) (n int, err error)', 'kind': '', 'abbr': 'func Scan(a ...interface{}) (n int, err error)'}
" deoplete
" {'word': 'Errorf', 'menu': '', 'info': 'func(format string, a ...interface{}) error', 'kind': 'func', 'abbr': 'Errorf(format string, a ...interface{}) error'}
function! s:parser1(info) "{{{
if empty(a:info)
return []
endif
let param = substitute(a:info, '\m^func\%( \w*\)\?\(.*\)', '\1', '')
while param =~# '\m\<func\>'
let param = substitute(param, '\<func\>\s*([^()]*)\s*\%(\w*|([^()]*)\)\?', '', 'g')
endwhile
let param = substitute(param, '\m^\(([^()]*)\).*', '\1', '')
" remove type
let param = substitute(param, '\m\(\w\+\)\s*[^,)]*', '\1', 'g')
return [param]
endfunction "}}}
function! cm_parser#go#parameters(completed_item) "{{{
let menu = get(a:completed_item, 'menu', '')
let info = get(a:completed_item, 'info', '')
if menu =~# '^func'
return <SID>parser1(menu)
elseif info =~# '^func'
return <SID>parser1(info)
else
return []
endif
endfunction "}}}
function! cm_parser#go#parameter_delim() "{{{
return ','
endfunction "}}}
function! cm_parser#go#parameter_begin() "{{{
return '('
endfunction "}}}
function! cm_parser#go#parameter_end() "{{{
return ')'
endfunction "}}}
function! cm_parser#go#echos(completed_item) "{{{
let menu = get(a:completed_item, 'menu', '')
let info = get(a:completed_item, 'info', '')
if menu =~# '^func'
return [menu]
elseif info =~# '^func'
return [info]
endif
return []
endfunction "}}}

View File

@ -0,0 +1,117 @@
"==============================================================
" file: javascript.vim
" brief:
" VIM Version: 8.0
" author: tenfyzhong
" email: tenfy@tenfy.cn
" created: 2017-06-11 21:14:37
"==============================================================
function! s:process_param(param)
let param = a:param
" remove fn
while param =~# '\<fn('
let param = substitute(param, '\m\<fn([^)]*)', '', 'g')
endwhile
" both parameter and the type is object
" remove type
while param =~# '{[^{}]*}\s*:\s*{[^{}]*}'
let param = substitute(param, '\m\({[^{}]*}\)\s*:\s*{[^{}]*}', '\1', 'g')
endwhile
" if the type of parameter is an object
" return object but not parameter
while param =~# '\w\+\s*:\s*{[^{}]*}'
let param = substitute(param, '\m\w\+:\s\({[^{}]*}\)', '\1', 'g')
endwhile
let param = substitute(param, '\m?\?:\s*[^,(){}]*', '', 'g')
return param
endfunction
" ycm
function! s:parser0(menu) "{{{
let param = substitute(a:menu, '\m^fn\((.*)\)\%(\s*->.*\)\?', '\1', '')
let param = <sid>process_param(param)
return [param]
endfunction "}}}
" deoplete
function! s:check_parentheses_pairs(line) "{{{
let left = 0
let right = 0
let i = 0
while i < len(a:line)
if a:line[i] ==# '('
let left += 1
elseif a:line[i] ==# ')'
let right += 1
endif
let i += 1
endwhile
return left == right
endfunction "}}}
function! s:parser1(info) "{{{
let info_lines = split(a:info, '\n')
let func = info_lines[0]
for line in info_lines[1:]
if <SID>check_parentheses_pairs(func)
break
endif
let func .= line
endfor
let param = substitute(func, '\m^fn\((.*)\)\%(\s*->.*\)\?', '\1', '')
let param = <sid>process_param(param)
return [param]
endfunction "}}}
function! s:parser2(menu) "{{{
let param = '(' . a:menu . ')'
let param = <SID>process_param(param)
return [param]
endfunction "}}}
function! cm_parser#javascript#parameters(completed_item) "{{{
let menu = get(a:completed_item, 'menu', '')
let info = get(a:completed_item, 'info', '')
let kind = get(a:completed_item, 'kind', '')
let word = get(a:completed_item, 'word', '')
if menu =~# '\m^fn('
return <SID>parser0(menu)
elseif info =~# '\m^fn('
return <SID>parser1(info)
elseif word =~# '\m\w\+(' && empty(info) && kind ==# 'f' && !empty(menu)
" ycm omni
" {'word': 'add(', 'menu': 'a, b', 'info': '', 'kind': 'f', 'abbr': ''}
return <SID>parser2(menu)
endif
return []
endfunction "}}}
function! cm_parser#javascript#parameter_delim() "{{{
return ','
endfunction "}}}
function! cm_parser#javascript#parameter_begin() "{{{
return '({'
endfunction "}}}
function! cm_parser#javascript#parameter_end() "{{{
return ')}'
endfunction "}}}
function! cm_parser#javascript#echos(completed_item) "{{{
let menu = get(a:completed_item, 'menu', '')
let info = get(a:completed_item, 'info', '')
let kind = get(a:completed_item, 'kind', '')
let word = get(a:completed_item, 'word', '')
if menu =~# '\m^fn('
return [menu]
elseif info =~# '\m^fn('
return [info]
elseif word =~# '\m\w\+(' && empty(info) && kind ==# 'f' && !empty(menu)
return [word.menu.')']
endif
return []
endfunction "}}}

View File

@ -0,0 +1,140 @@
"==============================================================
" file: python.vim
" brief:
" VIM Version: 8.0
" author: tenfyzhong
" email: tenfy@tenfy.cn
" created: 2017-06-11 18:11:12
"==============================================================
" pexpect
" interact(self, escape_character=chr(29), input_filter=None,
" output_filter=None)
function! s:signature(info) "{{{
let info_lines = split(a:info, '\n')
let func = ''
let match = 0
let l:finish = 0
if info_lines[0] !~# '('
if info_lines[0] !~# '```' || len(info_lines) == 1 || info_lines[1] !~# '('
return func
endif
endif
" there are maybe some () in the parameters
" if the count of `(` equal to `)`
" then the parameters has finished
for line in info_lines
for i in range(len(line))
if line[i] ==# '('
let match += 1
elseif line[i] ==# ')'
let match -= 1
if match == 0
let l:finish = 1
break
endif
endif
endfor
if l:finish == 0
let func .= line
else
let func .= line[:i]
break
endif
endfor
return func
endfunction "}}}
function! s:parser0(info) "{{{
let func = <SID>signature(a:info)
" remove function name, begin `(` and end `)`
let param = substitute(func, '\m[^(]*(\(.*\))[^)]*', '\1', '')
let keep_default_value = get(g:, 'complete_parameter_py_keep_value', 1)
let remove_default_parameter = get(g:, 'complete_parameter_py_remove_default', 1)
if !keep_default_value
" remove `()`
while param =~# '(.*)'
let param = substitute(param, '(.*)', '', 'g')
endwhile
endif
" add begin`(` and end`)`
let param = '(' . param . ')'
if remove_default_parameter
let param = substitute(param, '\m\s*,\?\s*\w*\s*=.*', ')', '')
let param = substitute(param, '\m\s*,\?\s*\.\.\..*', ')', '')
let param = substitute(param, '\m\s*,\?\s*\*args.*', ')', '')
elseif !keep_default_value
let param = substitute(param, '\m\s*=\s*[^,()]*', '', 'g')
endif
" remove `[` and `]`
let param = substitute(param, '\m\[\|\]', '', 'g')
" remove self,cls
let param = substitute(param, '\m(\s*\<self\>\s*,\?', '(', '')
let param = substitute(param, '\m(\s*\<cls\>\s*,\?', '(', '')
" remove space
let param = substitute(param, '\m\s\+', ' ', 'g')
let param = substitute(param, '\m\s,', ',', 'g')
let param = substitute(param, '\m(\s', '(', '')
let param = substitute(param, '\m,\s*)', ')', '')
let param = substitute(param, '\m,\(\S\)', ', \1', 'g')
return [param]
endfunction "}}}
" deoplete
" {'word': 'call_tracing(', 'menu': '', 'info': 'call_tracing(func, args) -> object^@^@Call func(*args), while tracing is enabled. The tracing state is^@saved, and restored afterwards. This is intended to be called from^@a debugger from a checkpoint, to recursively debug some other code.', 'kind': '', 'abbr': 'call_tracing(func, args)'}
function! cm_parser#python#parameters(completed_item) "{{{
let menu = get(a:completed_item, 'menu', '')
let info = get(a:completed_item, 'info', '')
let word = get(a:completed_item, 'word', '')
let abbr = get(a:completed_item, 'abbr', '')
let kind = get(a:completed_item, 'kind', '')
if (menu =~# '\m^\%(function:\|def \)' || word =~# '\m^\w\+($' || menu =~? '\[jedi\]\s*') && !empty(info)
return s:parser0(info)
" From language server.
elseif menu =~? '\[LS\]' && !empty(info)
return s:parser0(info)
elseif word ==# '(' && empty(menu) && info ==# ' ' && empty(kind) && !empty(abbr)
" ycm omni called
" {'word': '(', 'menu': '', 'info': ' ', 'kind': '', 'abbr': 'add(a,b)'}
return s:parser0(abbr)
endif
return []
endfunction "}}}
function! cm_parser#python#parameter_delim() "{{{
return ','
endfunction "}}}
function! cm_parser#python#parameter_begin() "{{{
return '('
endfunction "}}}
function! cm_parser#python#parameter_end() "{{{
return ')'
endfunction "}}}
function! cm_parser#python#echos(completed_item) "{{{
let menu = get(a:completed_item, 'menu', '')
let info = get(a:completed_item, 'info', '')
let word = get(a:completed_item, 'word', '')
let abbr = get(a:completed_item, 'abbr', '')
let kind = get(a:completed_item, 'kind', '')
if (menu =~# '\m^\%(function:\|def \)' || word =~# '\m^\w\+($' || menu =~? '\[jedi\]\s*') && !empty(info)
return [s:signature(info)]
elseif word ==# '(' && empty(menu) && info ==# ' ' && empty(kind) && !empty(abbr)
" ycm omni called
" {'word': '(', 'menu': '', 'info': ' ', 'kind': '', 'abbr': 'add(a,b)'}
return [s:signature(abbr)]
endif
return []
endfunction "}}}

View File

@ -0,0 +1,79 @@
"==============================================================
" file: rust.vim
" brief:
" VIM Version: 8.0
" author: tenfyzhong
" email: tenfy@tenfy.cn
" created: 2017-06-11 19:32:37
"==============================================================
" ycm
" {'word': 'gen_range', 'menu': 'fn gen_range<T: PartialOrd + SampleRange>(&mut self, low: T, high: T) -> T where Self: Sized', 'info': '', 'kind': 'f', 'abbr': ''}
" {'word': 'trim', 'menu': 'pub fn trim(&self) -> &str', 'info': '', 'kind': 'f', 'abbr': ''}
"
" deoplete
" {'word': 'from_raw_parts', 'menu': '[Rust] pub unsafe fn from_raw_parts(ptr: *mut T', 'info': 'pub unsafe fn from_raw_parts(ptr: *mut T, length: usize, capacity: usize) -> Vec<T>', 'kind': 'Function', 'abbr': 'from_raw_parts'})'
"
" neocomplete+vim-racer
" {'word': 'from_raw_parts(', 'menu': '[O] unsafe from_raw_parts(ptr: *mut T, length: usize, capacity: usize) -> Vec<T>', 'info': 'pub unsafe fn from_raw_parts(ptr: *mut T, length: usize, capacity: usize) -> Vec<T>', 'kind': 'f', 'abbr': 'from_raw_parts'}
'
function! s:parse(word, param) "{{{
" check is fn or not
let param = substitute(a:param, '\m.*'.a:word.'\%(<.*>\)\?\(([^)]*)\).*', '\1', '')
while param =~# '\m<.*>'
let param = substitute(param, '\m<[^>]*>', '', 'g')
endwhile
let param = substitute(param, '\m:\s*[^,)]*', '', 'g')
let param = substitute(param, '\m(&\?\%(\s*\&''\w\+\s*\)\?\%(\s*mut\s\+\)\?self\s*\([,)]\)', '(\1', '')
let param = substitute(param, '\m(\s*,\s*', '(', '')
return [param]
endfunction "}}}
" TODO support template
function! cm_parser#rust#parameters(completed_item) "{{{
let menu = get(a:completed_item, 'menu', '')
let word = get(a:completed_item, 'word', '')
let kind = get(a:completed_item, 'kind', '')
let info = get(a:completed_item, 'info', '')
let l:abbr = get(a:completed_item, 'abbr', '')
if kind ==# 'f' && !empty(word) && menu =~# '(.*)' && empty(info)
" ycm
return <SID>parse(word, menu)
elseif kind ==# 'f' && !empty(l:abbr) && word =~# l:abbr.'(' && !empty(info)
return <SID>parse(l:abbr, info)
elseif kind ==# 'Function' && !empty(word) && info =~# '(.*)'
" deoplete
return <SID>parse(word, info)
endif
return []
endfunction "}}}
function! cm_parser#rust#parameter_delim() "{{{
return ','
endfunction "}}}
function! cm_parser#rust#parameter_begin() "{{{
return '('
endfunction "}}}
function! cm_parser#rust#parameter_end() "{{{
return ')'
endfunction "}}}
function! cm_parser#rust#echos(completed_item) "{{{
let menu = get(a:completed_item, 'menu', '')
let word = get(a:completed_item, 'word', '')
let kind = get(a:completed_item, 'kind', '')
let info = get(a:completed_item, 'info', '')
let l:abbr = get(a:completed_item, 'abbr', '')
if kind ==# 'f' && !empty(word) && menu =~# '(.*)' && empty(info)
" ycm
return [menu]
elseif kind ==# 'f' && !empty(l:abbr) && word =~# l:abbr.'(' && !empty(info)
return [info]
elseif kind ==# 'Function' && !empty(word) && info =~# '(.*)'
" deoplete
return [info]
endif
return []
endfunction "}}}

View File

@ -0,0 +1,94 @@
"==============================================================
" file: typescript.vim
" brief:
" VIM Version: 8.0
" author: tenfyzhong
" email: tenfy@tenfy.cn
" created: 2017-06-17 08:56:21
"==============================================================
function! s:parser0(word, abbr) "{{{
let param = a:abbr
" remove ()
while param =~# '\m: ([^()]*)'
let param = substitute(param, '\m: \zs([^()]*)', '', 'g')
endwhile
" remove []
while param =~# '\m\[[^[]*\]'
let param = substitute(param, '\m\[[^[]*\]', '', 'g')
endwhile
" fun (method) A.fun()
let pattern = printf('\m^%s\s*(method)\s*.*%s\%%(<[^()<>]*>\)\?(\([^()]*\)).*', a:word, a:word)
let param = substitute(param, pattern, '\1', '')
let param = substitute(param, ':[^,)]*', '', 'g')
let param = substitute(param, '?\?', '', 'g')
let param = '('.param.')'
return [param]
endfunction "}}}
" neocomplete
" {'word': 'concat', 'menu': '(method) Array<number>.concat<number>(...items: number[][]): number[] (+1 overload)', 'info': '', 'kind': '', 'abbr': ''}
" deoplete
" {'word': 'concat', 'menu': 'TS Array<number>.concat<number>(...i..(+1 overload)', 'info': 'Array<number>.concat<number>(...items: number[][]): number[] (+1 overload)^@Combines two or more arrays.', 'kind': 'M', 'abbr': 'concat'}
function! s:parser1(word, info) "{{{
let param = split(a:info, '\n')[0]
let pattern = printf('\m^.*%s[^(]*(\(.*\)', a:word)
let param = substitute(param, pattern, '\1', '')
let param = substitute(param, '\m([^()]*)', '', 'g')
let param = substitute(param, '\m\[[^\[\]]*\]', '', 'g')
let param = substitute(param, '\m).*', '', '')
let param = substitute(param, ':[^,)]*', '', 'g')
let param = substitute(param, '?\?', '', 'g')
let param = '('.param.')'
return [param]
endfunction "}}}
function! cm_parser#typescript#parameters(completed_item) "{{{
let kind = get(a:completed_item, 'kind', '')
let l:abbr = get(a:completed_item, 'abbr', '')
let word = get(a:completed_item, 'word', '')
let info = get(a:completed_item, 'info', '')
let l:menu = get(a:completed_item, 'menu', '')
if kind ==# 'm' && l:abbr =~# '\m^'.word.'\s*(method)'
return <SID>parser0(word, l:abbr)
elseif (kind ==# 'm' || kind ==# 'M') && info =~# '\m\<'.word.'\>\%(<[^<>()]*>\)\?('
return <SID>parser1(word, info)
elseif empty(kind) && l:menu =~# '\m^(method).*'.word
return <SID>parser1(word, l:menu)
endif
return []
endfunction "}}}
function! cm_parser#typescript#parameter_delim() "{{{
return ','
endfunction "}}}
function! cm_parser#typescript#parameter_begin() "{{{
return '('
endfunction "}}}
function! cm_parser#typescript#parameter_end() "{{{
return ')'
endfunction "}}}
function! cm_parser#typescript#echos(completed_item) "{{{
let kind = get(a:completed_item, 'kind', '')
let word = get(a:completed_item, 'word', '')
let l:abbr = get(a:completed_item, 'abbr', '')
let info = get(a:completed_item, 'info', '')
let l:menu = get(a:completed_item, 'menu', '')
if kind ==# 'm' && l:abbr =~# '\m^'.word.'\s*(method)'
return [l:abbr]
elseif (kind ==# 'm' || kind ==# 'M') && info =~# '\m\<'.word.'\>\%(<[^<>()]*>\)\?('
return [info]
elseif empty(kind) && l:menu =~# '\m^(method).*'.word
return [l:menu]
endif
return []
endfunction "}}}

View File

@ -0,0 +1 @@
tags

View File

@ -0,0 +1,258 @@
*complete_parameter* *CompleteParameter* *completeparameter* author: tenfyzhong
This help file explains the CompleteParameter Vim Plugin.
================================================================================
Contents:
0. Introduction -------------------------------- |complete-parameter-introduction|
1. Install ------------------------------------- |complete-parameter-install|
2. Usage --------------------------------------- |complete-parameter-usage|
3. Mapping ------------------------------------- |complete-parameter-mapping|
4. Options ------------------------------------- |complete-parameter-options|
5. Functions ----------------------------------- |complete-parameter-functions|
6. Writing Extensions -------------------------- |complete-parameter-extensions|
7. FAQ ----------------------------------------- |complete-parameter-faq|
8. Contributions ------------------------------- |complete-parameter-contributes|
9. Thanks -------------------------------------- |complete-parameter-thanks|
10. LICENSE ------------------------------------ |complete-parameter-license|
================================================================================
0. Introduction *complete-parameter-introduction*
CompletEparameter is a plugin for complete function's parameters after complete
a function.
- Complete parameters after select a complete item from the completion popup menu.
- After complete the parameters, jump to the first parameter and the select it.
- Jump to next parameter.
- Jump to previous parameter.
- Select next overload function.
- Select previous overload function.
- Select the first item in the completion popup menu.
- Echo signature when select an item. (need to `set noshowmode` or `set cmdheight=2`)
================================================================================
1. Install *complete-parameter-install*
I suggest you to use a plugin manager, such vim-plug or other.
- [vim-plug](https://github.com/junegunn/vim-plug) >
Plug 'tenfyzhong/CompleteParameter.vim'
<
- Manual >
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!
<
================================================================================
2. Usage *complete-parameter-usage*
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.
## Minimal setting >
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)
<
================================================================================
3. Mapping *complete-parameter-mapping*
*<Plug>(complete_parameter#goto_next_parameter)*
`<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)*
`<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)*
`<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)*
`<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)
<
================================================================================
4. Options *complete-parameter-options*
*g:complete_parameter_log_level*
* g:complete_parameter_log_level
This option set the log level.
5: disable log.
4: only print **error** log.
2: print **error** and **debug** log.
1: print **error**, **debug**, **trace**
Default: 5 >
let g:complete_parameter_log_level = 5
<
*g:complete_parameter_use_ultisnips_mappings*
* g:complete_parameter_use_ultisnips_mappings
If 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*
* g:complete_parameter_echo_signature
It 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*
* g:complete_parameter_py_keep_value
It will keep default value if it 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*
* g:complete_parameter_py_remove_default
It 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
<
================================================================================
5. Functions *complete-parameter-functions*
*cmp#pre_complete*
*complete_parameter#pre_complete*
`cmp#pre_complete(failed_insert)`
`complete_parameter#pre_complete(failed_insert)` deprecated
call parameter completion. If failed, the parameter `failed_insert` will be
inserted.
*cmp#jumpable*
*complete_parameter#jumpable*
`cmp#jumpable(forward)`
`complete_parameter#jumpable(forward)` deprecated
can jump to next parameter or not.
*CompleteParameterFailed*
`CompleteParameterFailed(failed_insert)`
You can define this function and process the failed event. The return will be
inserted.
================================================================================
6. Writing Extensions *complete-parameter-extensions*
It's easy to writing extensions for languages.
Follow the next steps. All commands below was work in this plugin directory.
1) Create a file named `filetype.vim` in path `cm_parser`. For example,
write extension for golang. >
touch cm_parser/go.vim
<
2) Create function: `cm_parser#filetype#parameters(completed_item)`
This is the most important function.
The parameter `completed_item` is a copy of |v:completed_item|.
This function will parse the complete info from the `completed_item` and
return the parameters you need to completed.
The return must be a list of strings. So the overwrite functions can be returned.
For example, a go function like
`func Dial(network string, address string) (net.Conn, error)`
The function message was stored in the `menu` field of `completed_item`
The go no support overwrite. So the result is `['(network, address)']`
For another example, the std::vector::erase functor of c++, there are two
overwrite functions. The message was stored in the `info` field of
`completed_item`
`iterator erase( const_iterator __position )`
`iterator erase( const_iterator __first, const_iterator __last )`
This function will return: `['(__position)', '(__first, __last)']`
3) Create function `cm_parser#filetype#parameter_delim()`
This function return the delim of parameters. For example, the go and c++
will return ','
4) Create function `cm_parser#filetype#parameter_begin()`
This function return the border begin of the parameters. For example, the go
will return '('. C++ will return '(<', the '<' is the beginning of
template parameters.
5) Create function `cm_parser#filetype#parameter_end()`
This function return the border end of the parameters. For example, the go
will return ')'. C++ will return ')>', the '>' is ending of
template parameters.
The length of `cm_parser#filetype#parameter_begin()` and
`cm_parser#filetype#parameter_end()` must be equal. Each char of them must
be match. For example, the the first char of begin is '(', the first of end
must be ')'.
6) Create function `cm_parser#filetype#echos(completed_item)`
This function return the signatures. When the parameter completed, the
signature will echo to cmd window. It's optional.
7) Please write unittest for your function `cm_parser#filetype#parameters`
use [vader](https://github.com/junegunn/vader.vim) test framework. And put
the unittest in the `vader` directory. This is optional. But if you would
send a pull request, this is required.
Finally, please send a pull request for me if you would like to share you
extension.
================================================================================
7. FAQ *complete-parameter-faq*
1) Can't work with plugin auto-pairs use the default mapping `(`
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>
<
2) How to accept the selected function but not parameters
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.
3) The mapping `<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.
================================================================================
8. Contributions *complete-parameter-contributes*
Contributions and pull requests are welcome.
================================================================================
9. Thanks *complete-parameter-thanks*
- [johnzeng](https://github.com/johnzeng), support erlang
================================================================================
10. LICENSE *complete-parameter-license*
MIT License Copyright (c) 2017 tenfyzhong
" vim:ft=help:iskeyword+=-:iskeyword+=58:iskeyword+=#

View File

@ -0,0 +1,40 @@
"==============================================================
" file: complete_parameter.vim
" brief:
" VIM Version: 8.0
" author: tenfyzhong
" email: tenfy@tenfy.cn
" created: 2017-06-07 20:27:49
"==============================================================
if (!has('nvim')&&version < 704) ||
\(!has('nvim')&&version==704&&!has('patch774')) ||
\&compatible ||
\exists('g:complete_parameter_version')
finish
endif
let g:complete_parameter_version = "0.8.2"
lockvar g:complete_parameter_version
let save_cpo = &cpo
set cpo&vim
call cmp#init()
nnoremap <silent> <Plug>(complete_parameter#goto_next_parameter) <ESC>:call cmp#goto_next_param(1)<cr>
snoremap <silent> <Plug>(complete_parameter#goto_next_parameter) <ESC>:call cmp#goto_next_param(1)<cr>
inoremap <silent> <Plug>(complete_parameter#goto_next_parameter) <ESC>:call cmp#goto_next_param(1)<cr>
nnoremap <silent> <Plug>(complete_parameter#goto_previous_parameter) <ESC>:call cmp#goto_next_param(0)<cr>
snoremap <silent> <Plug>(complete_parameter#goto_previous_parameter) <ESC>:call cmp#goto_next_param(0)<cr>
inoremap <silent> <Plug>(complete_parameter#goto_previous_parameter) <ESC>:call cmp#goto_next_param(0)<cr>
nnoremap <silent> <Plug>(complete_parameter#overload_down) <ESC>:call cmp#overload_next(1)<cr>
snoremap <silent> <Plug>(complete_parameter#overload_down) <ESC>:call cmp#overload_next(1)<cr>
inoremap <silent> <Plug>(complete_parameter#overload_down) <ESC>:call cmp#overload_next(1)<cr>
nnoremap <silent> <Plug>(complete_parameter#overload_up) <ESC>:call cmp#overload_next(0)<cr>
snoremap <silent> <Plug>(complete_parameter#overload_up) <ESC>:call cmp#overload_next(0)<cr>
inoremap <silent> <Plug>(complete_parameter#overload_up) <ESC>:call cmp#overload_next(0)<cr>
let &cpo = save_cpo

View File

@ -0,0 +1,135 @@
"{{{ycm
Execute (error param):
let completed_item = {}
let result = cm_parser#c#parameters(completed_item)
AssertEqual [], result
Execute (error param, kind != f):
let completed_item = {'kind': 't'}
let result = cm_parser#c#parameters(completed_item)
AssertEqual [], result
Execute (error param, abbr == ''):
let completed_item = {'kind': 'f', 'abbr': ''}
let result = cm_parser#c#parameters(completed_item)
AssertEqual [], result
Execute (fun()):
let completed_item = {'kind': 'f', 'abbr': 'fun()'}
let result = cm_parser#c#parameters(completed_item)
AssertEqual ['()'], result
Execute (fun(int)):
let completed_item = {'kind': 'f', 'abbr': 'fun(int)'}
let result = cm_parser#c#parameters(completed_item)
AssertEqual ['(int)'], result
Execute (fun(struct tm *const)):
let completed_item = {'kind': 'f', 'abbr': 'fun(struct tm *const)'}
let result = cm_parser#c#parameters(completed_item)
AssertEqual ['(const)'], result
Execute (fun(const char *)):
let completed_item = {'kind': 'f', 'abbr': 'fun(const char *)'}
let result = cm_parser#c#parameters(completed_item)
AssertEqual ['(char)'], result
Execute (fun(const char **)):
let completed_item = {'kind': 'f', 'abbr': 'fun(const char **)'}
let result = cm_parser#c#parameters(completed_item)
AssertEqual ['(char)'], result
Execute (fun(const char *a, int b)):
let completed_item = {'kind': 'f', 'abbr': 'fun(const char *a, int b)'}
let result = cm_parser#c#parameters(completed_item)
AssertEqual ['(a, b)'], result
Execute (fun( const struct tm *restrict, char *restrict )):
let completed_item = {'kind': 'f', 'abbr': 'fun( const struct tm *restrict, char *restrict )'}
let result = cm_parser#c#parameters(completed_item)
AssertEqual ['(restrict, restrict)'], result
Execute (CMP, kind: m):
let completed_item = {'word': 'CMP', 'menu': '', 'info': ' CMP( a, b )^@', 'kind': 'm', 'abbr': 'CMP( a, b )'}
let result = cm_parser#c#parameters(completed_item)
AssertEqual ['(a, b)'], result
"}}}
"{{{ deoplete
Execute (fun()):
let completed_item = {'kind': 'f void', 'abbr': 'fun()', 'word': 'fun', 'menu': '[clang] '}
let result = cm_parser#c#parameters(completed_item)
AssertEqual ['()'], result
Execute (fun(int)):
let completed_item = {'kind': 'f void', 'abbr': 'fun(int)', 'word': 'fun', 'menu': '[clang] '}
let result = cm_parser#c#parameters(completed_item)
AssertEqual ['(int)'], result
Execute (fun(struct tm *const)):
let completed_item = {'kind': 'f', 'abbr': 'fun(struct tm *const)', 'word': 'fun', 'menu': '[clang] '}
let result = cm_parser#c#parameters(completed_item)
AssertEqual ['(const)'], result
Execute (fun(const char *)):
let completed_item = {'kind': 'f void', 'abbr': 'fun(const char *)', 'word': 'fun', 'menu': '[clang] '}
let result = cm_parser#c#parameters(completed_item)
AssertEqual ['(char)'], result
Execute (fun(const char **)):
let completed_item = {'kind': 'f void', 'abbr': 'fun(const char **)', 'word': 'fun', 'menu': '[clang] '}
let result = cm_parser#c#parameters(completed_item)
AssertEqual ['(char)'], result
Execute (fun(const char *a, int b)):
let completed_item = {'kind': 'f void', 'abbr': 'fun(const char *a, int b)', 'word': 'fun', 'menu': '[clang] '}
let result = cm_parser#c#parameters(completed_item)
AssertEqual ['(a, b)'], result
Execute (fun( const struct tm *restrict, char *restrict )):
let completed_item = {'kind': 'f void', 'abbr': 'fun( const struct tm *restrict, char *restrict )', 'word': 'fun', 'menu': '[clang] '}
let result = cm_parser#c#parameters(completed_item)
AssertEqual ['(restrict, restrict)'], result
"}}}
"{{{ clang_complete
Execute (fun()):
let completed_item = {'kind': 'f', 'menu': 'void fun()', 'word': 'fun', 'abbr': 'fun'}
let result = cm_parser#c#parameters(completed_item)
AssertEqual ['()'], result
Execute (fun(int)):
let completed_item = {'kind': 'f', 'menu': 'void fun(int)', 'word': 'fun', 'abbr': 'fun'}
let result = cm_parser#c#parameters(completed_item)
AssertEqual ['(int)'], result
Execute (fun(struct tm *const)):
let completed_item = {'kind': 'f', 'menu': 'void fun(struct tm *const)', 'word': 'fun', 'abbr': 'fun'}
let result = cm_parser#c#parameters(completed_item)
AssertEqual ['(const)'], result
Execute (fun(const char *)):
let completed_item = {'kind': 'f', 'menu': 'void fun(const char *)', 'word': 'fun', 'abbr': 'fun'}
let result = cm_parser#c#parameters(completed_item)
AssertEqual ['(char)'], result
Execute (fun(const char *a, int b)):
let completed_item = {'kind': 'f', 'menu': 'void fun(const char *a, int b)', 'word': 'fun', 'abbr': 'fun'}
let result = cm_parser#c#parameters(completed_item)
AssertEqual ['(a, b)'], result
Execute (fun(const char **)):
let completed_item = {'kind': 'f', 'menu': 'void fun(const char **)', 'word': 'fun', 'abbr': 'fun'}
let result = cm_parser#c#parameters(completed_item)
AssertEqual ['(char)'], result
Execute (fun( const struct tm *restrict, char *restrict )):
let completed_item = {'kind': 'f', 'menu': 'void fun( const struct tm *restrict, char *restrict )', 'word': 'fun', 'abbr': 'fun'}
let result = cm_parser#c#parameters(completed_item)
AssertEqual ['(restrict, restrict)'], result
Execute (coc.nvim + ccls):
let completed_item = {'word': 'fun', 'menu': '[LS]', 'user_data': '{"cid":1578967270,"source":"languageserver.ccls","index":0}', 'info': '', 'kind': 'f', 'abbr': 'fun(int x, int y) -> int~'}
let result = cm_parser#c#parameters(completed_item)
AssertEqual ['(x, y)'], result
"}}}

View File

@ -0,0 +1,14 @@
Before:
inoremap <silent><expr> ( cmp#pre_complete("()")
Given go (func haha):
func haha
Do:
9|a(
Expect go ():
func haha()
Then:
AssertEqual 10, col('.')

View File

@ -0,0 +1,118 @@
"{{{ycm
Execute (error completed_item):
let completed_item = {}
let result = cm_parser#cpp#parameters(completed_item)
AssertEqual [], result
Execute (error completed_item, kind: t):
let completed_item = {'kind': 't'}
let result = cm_parser#cpp#parameters(completed_item)
AssertEqual [], result
Execute (error completed_item, word empty):
let completed_item = {'kind': 'f', 'word': ''}
let result = cm_parser#cpp#parameters(completed_item)
AssertEqual [], result
Execute (error completed_item, word info):
let completed_item = {'kind': 'f', 'word': 'empty'}
let result = cm_parser#cpp#parameters(completed_item)
AssertEqual [], result
Execute (vector::empty()):
let completed_item = {'kind': 'f', 'word': 'empty', 'info': "bool empty() const\n"}
let result = cm_parser#cpp#parameters(completed_item)
AssertEqual ['()'], result
Execute (vector::operator=):
let completed_item = {'kind': 'f', 'word': 'operator=', 'info': "std::vector<int, std::allocator<int> > & operator=( const std::vector<int, std::allocator<int> > &__x )"}
let result = cm_parser#cpp#parameters(completed_item)
AssertEqual ['(__x)'], result
Execute (vector::vector):
let completed_item = {'kind': 'f', 'word': 'vector', 'info': "void vector( _InputIterator __first, typename enable_if<__is_input_iterator<_InputIterator>::value && !__is_forward_iterator<_InputIterator>::value && is_constructible<value_type, typename iterator_traits<_InputIterator>::reference>::value, _InputIterator>::type __last )\nvoid vector( _InputIterator __first, _InputIterator __last, const allocator_type &__a, typename enable_if<__is_input_iterator<_InputIterator>::value && !__is_forward_iterator<_InputIterator>::value && is_constructible<value_type, typename iterator_traits<_InputIterator>::reference>::value>::type * )"}
let result = cm_parser#cpp#parameters(completed_item)
AssertEqual ['(__first, __last)', '(__first, __last, __a, *)'], result
Execute (ctime::time):
let completed_item = {'kind':'f', 'word': 'time', 'info': 'time_t time( time_t * )'}
let result = cm_parser#cpp#parameters(completed_item)
AssertEqual ['(*)'], result
Execute (vector<class _Tp, class _Alloc>, kind: c):
let completed_item = {'kind': 'c', 'word': 'vector', 'info': "vector<class _Tp, class _Alloc>\n"}
let result = cm_parser#cpp#parameters(completed_item)
AssertEqual ['<_Tp, _Alloc>'], result
Execute (std::error_code, kind: c):
let completed_item = {'kind': 'c', 'word': 'error_code', 'info': "error_code"}
let result = cm_parser#cpp#parameters(completed_item)
AssertEqual [], result
Execute (std:: error_code, kind: c):
let completed_item = {'kind': 'c', 'word': 'error_code', 'info': " error_code"}
let result = cm_parser#cpp#parameters(completed_item)
AssertEqual [], result
Execute (CMP, kind: m):
let completed_item = {'word': 'CMP', 'menu': '', 'info': ' CMP( a, b )^@', 'kind': 'm', 'abbr': 'CMP( a, b )'}
let result = cm_parser#cpp#parameters(completed_item)
AssertEqual ['(a, b)'], result
Execute (include default func value):
let completed_item = {'word': 'test', 'menu': 'void', 'info': 'void test(int a, int b = func() )', 'kind': 'f', 'abbr': 'test( int a, int b = func() )'}
let result = cm_parser#cpp#parameters(completed_item)
AssertEqual ['(a, b)'], result
Execute (include default value):
let completed_item = {'word': 'test1', 'menu': 'void', 'info': 'void test1( int a, int b = 1 )', 'kind': 'f', 'abbr': 'test1( int a, int b = 1 )'}
let result = cm_parser#cpp#parameters(completed_item)
AssertEqual ['(a, b)'], result
"}}}
"{{{deoplete
Execute (error completed_item, word empty):
let completed_item = {'kind': 'f void', 'word': ''}
let result = cm_parser#cpp#parameters(completed_item)
AssertEqual [], result
Execute (error completed_item, word info):
let completed_item = {'kind': 'f void', 'word': 'empty'}
let result = cm_parser#cpp#parameters(completed_item)
AssertEqual [], result
Execute (vector::empty()):
let completed_item = {'kind': 'f bool', 'word': 'empty', 'info': "bool empty() const", 'menu': '[clang] '}
let result = cm_parser#cpp#parameters(completed_item)
AssertEqual ['()'], result
Execute (vector::operator=):
let completed_item = {'kind': 'f std::vector<int, std::allocator<ing> > &', 'word': 'operator=', 'info': "std::vector<int, std::allocator<int> > & operator=( const std::vector<int, std::allocator<int> > &__x )", 'menu': '[clang] '}
let result = cm_parser#cpp#parameters(completed_item)
AssertEqual ['(__x)'], result
Execute (vector::vector):
let completed_item = {'kind': 'f', 'word': 'vector', 'info': "void vector( _InputIterator __first, typename enable_if<__is_input_iterator<_InputIterator>::value && !__is_forward_iterator<_InputIterator>::value && is_constructible<value_type, typename iterator_traits<_InputIterator>::reference>::value, _InputIterator>::type __last )\nvoid vector( _InputIterator __first, _InputIterator __last, const allocator_type &__a, typename enable_if<__is_input_iterator<_InputIterator>::value && !__is_forward_iterator<_InputIterator>::value && is_constructible<value_type, typename iterator_traits<_InputIterator>::reference>::value>::type * )", 'menu': '[clang] '}
let result = cm_parser#cpp#parameters(completed_item)
AssertEqual ['(__first, __last)', '(__first, __last, __a, *)'], result
Execute (ctime::time):
let completed_item = {'kind':'f time_t', 'word': 'time', 'info': 'time_t time( time_t * )', 'menu': '[clang] '}
let result = cm_parser#cpp#parameters(completed_item)
AssertEqual ['(*)'], result
Execute (vector<class _Tp, class _Alloc>, kind: p):
let completed_item = {'kind': 'p ', 'word': 'vector', 'info': "vector<class _Tp, class _Alloc>\n", 'menu': '[clang] '}
let result = cm_parser#cpp#parameters(completed_item)
AssertEqual ['<_Tp, _Alloc>'], result
Execute (std::error_code, kind: p):
let completed_item = {'kind': 'p ', 'word': 'error_code', 'info': "error_code", 'menu': '[clang] '}
let result = cm_parser#cpp#parameters(completed_item)
AssertEqual [], result
Execute (std:: error_code, kind: p):
let completed_item = {'kind': 'p ', 'word': 'error_code', 'info': " error_code", 'menu': '[clang] '}
let result = cm_parser#cpp#parameters(completed_item)
AssertEqual [], result
"}}}

View File

@ -0,0 +1,15 @@
Execute (func() -> undefined):
let completed_item = {'info': 'func() -> undefined'}
let result = cm_parser#erlang#parameters(completed_item)
AssertEqual ['()'], result
Execute (func(foo) -> ran()):
let completed_item = {'info': 'func(foo) -> ran()'}
let result = cm_parser#erlang#parameters(completed_item)
AssertEqual ['(foo)'], result
Execute (func(foo, bar) -> undefined | ran()):
let completed_item = {'info': 'func(foo, bar) -> undefined | ran()'}
let result = cm_parser#erlang#parameters(completed_item)
AssertEqual ['(foo, bar)'], result

View File

@ -0,0 +1,268 @@
"{{{ youcomplete
Execute (func()):
let completed_item = {'menu': 'func()', 'kind': 'f'}
let result = cm_parser#go#parameters(completed_item)
AssertEqual ['()'], result
Execute (func(a)):
let completed_item = {'menu': 'func(a)', 'kind': 'f'}
let result = cm_parser#go#parameters(completed_item)
AssertEqual ['(a)'], result
Execute (func(a int)):
let completed_item = {'menu': 'func(a int)', 'kind': 'f'}
let result = cm_parser#go#parameters(completed_item)
AssertEqual ['(a)'], result
Execute (func(a net.Conn)):
let completed_item = {'menu': 'func(a net.Conn)', 'kind': 'f'}
let result = cm_parser#go#parameters(completed_item)
AssertEqual ['(a)'], result
Execute (func(a net.Conn, b, c int)):
let completed_item = {'menu': 'func(a net.Conn, b, c int)', 'kind': 'f'}
let result = cm_parser#go#parameters(completed_item)
AssertEqual ['(a, b, c)'], result
Execute (func(a net.Conn, b, c int) error):
let completed_item = {'menu': 'func(a net.Conn, b, c int) error', 'kind': 'f'}
let result = cm_parser#go#parameters(completed_item)
AssertEqual ['(a, b, c)'], result
Execute (func(a net.Conn, b, c int) (int, error)):
let completed_item = {'menu': 'func(a net.Conn, b, c int) (int, error)', 'kind': 'f'}
let result = cm_parser#go#parameters(completed_item)
AssertEqual ['(a, b, c)'], result
Execute (func(a net.Conn, b, c int) (a int, err error)):
let completed_item = {'menu': 'func(a net.Conn, b, c int) (a int, err error)', 'kind': 'f'}
let result = cm_parser#go#parameters(completed_item)
AssertEqual ['(a, b, c)'], result
Execute (func(a net.Conn, b func()int, c int) (a int, err error)):
let completed_item = {'menu': 'func(a net.Conn, b func()int, c int) (a int, err error)', 'kind': 'f'}
let result = cm_parser#go#parameters(completed_item)
AssertEqual ['(a, b, c)'], result
Execute (func(a net.Conn, b func() int, c int) (a int, err error)):
let completed_item = {'menu': 'func(a net.Conn, b func() int, c int) (a int, err error)', 'kind': 'f'}
let result = cm_parser#go#parameters(completed_item)
AssertEqual ['(a, b, c)'], result
Execute (func(a net.Conn, b func(a int) int, c int) (a int, err error)):
let completed_item = {'menu': 'func(a net.Conn, b func(a int) int, c int) (a int, err error)', 'kind': 'f'}
let result = cm_parser#go#parameters(completed_item)
AssertEqual ['(a, b, c)'], result
Execute (func(a net.Conn, b func(a int), c int) (a int, err error)):
let completed_item = {'menu': 'func(a net.Conn, b func(a int), c int) (a int, err error)', 'kind': 'f'}
let result = cm_parser#go#parameters(completed_item)
AssertEqual ['(a, b, c)'], result
Execute (func(a net.Conn, b func(a func(a int) float) string, c int) (a int, err error)):
let completed_item = {'menu': 'func(a net.Conn, b func(a func(a int) float) string, c int) (a int, err error)', 'kind': 'f'}
let result = cm_parser#go#parameters(completed_item)
AssertEqual ['(a, b, c)'], result
"}}}
"{{{ completor
Execute (func()):
let completed_item = {'menu': 'func()'}
let result = cm_parser#go#parameters(completed_item)
AssertEqual ['()'], result
Execute (func(a)):
let completed_item = {'menu': 'func(a)'}
let result = cm_parser#go#parameters(completed_item)
AssertEqual ['(a)'], result
Execute (func(a int)):
let completed_item = {'menu': 'func(a int)'}
let result = cm_parser#go#parameters(completed_item)
AssertEqual ['(a)'], result
Execute (func(a net.Conn)):
let completed_item = {'menu': 'func(a net.Conn)'}
let result = cm_parser#go#parameters(completed_item)
AssertEqual ['(a)'], result
Execute (func(a net.Conn, b, c int)):
let completed_item = {'menu': 'func(a net.Conn, b, c int)'}
let result = cm_parser#go#parameters(completed_item)
AssertEqual ['(a, b, c)'], result
Execute (func(a net.Conn, b, c int) error):
let completed_item = {'menu': 'func(a net.Conn, b, c int) error'}
let result = cm_parser#go#parameters(completed_item)
AssertEqual ['(a, b, c)'], result
Execute (func(a net.Conn, b, c int) (int, error)):
let completed_item = {'menu': 'func(a net.Conn, b, c int) (int, error)'}
let result = cm_parser#go#parameters(completed_item)
AssertEqual ['(a, b, c)'], result
Execute (func(a net.Conn, b, c int) (a int, err error)):
let completed_item = {'menu': 'func(a net.Conn, b, c int) (a int, err error)'}
let result = cm_parser#go#parameters(completed_item)
AssertEqual ['(a, b, c)'], result
Execute (func(a net.Conn, b func()int, c int) (a int, err error)):
let completed_item = {'menu': 'func(a net.Conn, b func()int, c int) (a int, err error)'}
let result = cm_parser#go#parameters(completed_item)
AssertEqual ['(a, b, c)'], result
Execute (func(a net.Conn, b func() int, c int) (a int, err error)):
let completed_item = {'menu': 'func(a net.Conn, b func() int, c int) (a int, err error)'}
let result = cm_parser#go#parameters(completed_item)
AssertEqual ['(a, b, c)'], result
Execute (func(a net.Conn, b func(a int) int, c int) (a int, err error)):
let completed_item = {'menu': 'func(a net.Conn, b func(a int) int, c int) (a int, err error)'}
let result = cm_parser#go#parameters(completed_item)
AssertEqual ['(a, b, c)'], result
Execute (func(a net.Conn, b func(a int), c int) (a int, err error)):
let completed_item = {'menu': 'func(a net.Conn, b func(a int), c int) (a int, err error)'}
let result = cm_parser#go#parameters(completed_item)
AssertEqual ['(a, b, c)'], result
Execute (func(a net.Conn, b func(a func(a int) float) string, c int) (a int, err error)):
let completed_item = {'menu': 'func(a net.Conn, b func(a func(a int) float) string, c int) (a int, err error)'}
let result = cm_parser#go#parameters(completed_item)
AssertEqual ['(a, b, c)'], result
"}}}
"{{{ neocomplete
Execute (func Scan()):
let completed_item = {'info': 'func Scan()', 'word': 'Scan('}
let result = cm_parser#go#parameters(completed_item)
AssertEqual ['()'], result
Execute (func Scan(a)):
let completed_item = {'info': 'func Scan(a)', 'word': 'Scan('}
let result = cm_parser#go#parameters(completed_item)
AssertEqual ['(a)'], result
Execute (func Scan(a int)):
let completed_item = {'info': 'func Scan(a int)', 'word': 'Scan('}
let result = cm_parser#go#parameters(completed_item)
AssertEqual ['(a)'], result
Execute (func Scan(a net.Conn)):
let completed_item = {'info': 'func Scan(a net.Conn)', 'word': 'Scan('}
let result = cm_parser#go#parameters(completed_item)
AssertEqual ['(a)'], result
Execute (func Scan(a net.Conn, b, c int)):
let completed_item = {'info': 'func Scan(a net.Conn, b, c int)', 'word': 'Scan('}
let result = cm_parser#go#parameters(completed_item)
AssertEqual ['(a, b, c)'], result
Execute (func Scan(a net.Conn, b, c int) error):
let completed_item = {'info': 'func Scan(a net.Conn, b, c int) error', 'word': 'Scan('}
let result = cm_parser#go#parameters(completed_item)
AssertEqual ['(a, b, c)'], result
Execute (func Scan(a net.Conn, b, c int) (int, error)):
let completed_item = {'info': 'func Scan(a net.Conn, b, c int) (int, error)', 'word': 'Scan('}
let result = cm_parser#go#parameters(completed_item)
AssertEqual ['(a, b, c)'], result
Execute (func Scan(a net.Conn, b, c int) (a int, err error)):
let completed_item = {'info': 'func Scan(a net.Conn, b, c int) (a int, err error)', 'word': 'Scan('}
let result = cm_parser#go#parameters(completed_item)
AssertEqual ['(a, b, c)'], result
Execute (func(a net.Conn, b func()int, c int) (a int, err error)):
let completed_item = {'info': 'func fun(a net.Conn, b func()int, c int) (a int, err error)', 'word': 'fun('}
let result = cm_parser#go#parameters(completed_item)
AssertEqual ['(a, b, c)'], result
Execute (func(a net.Conn, b func() int, c int) (a int, err error)):
let completed_item = {'info': 'func fun(a net.Conn, b func() int, c int) (a int, err error)', 'word': 'func('}
let result = cm_parser#go#parameters(completed_item)
AssertEqual ['(a, b, c)'], result
Execute (func(a net.Conn, b func(a int) int, c int) (a int, err error)):
let completed_item = {'info': 'func fun(a net.Conn, b func(a int) int, c int) (a int, err error)', 'word': 'func('}
let result = cm_parser#go#parameters(completed_item)
AssertEqual ['(a, b, c)'], result
Execute (func(a net.Conn, b func(a int), c int) (a int, err error)):
let completed_item = {'info': 'func fun(a net.Conn, b func(a int), c int) (a int, err error)', 'word': 'func('}
let result = cm_parser#go#parameters(completed_item)
AssertEqual ['(a, b, c)'], result
Execute (func(a net.Conn, b func(a func(a int) float) string, c int) (a int, err error)):
let completed_item = {'info': 'func fun(a net.Conn, b func(a func(a int) float) string, c int) (a int, err error)', 'word': 'func('}
let result = cm_parser#go#parameters(completed_item)
AssertEqual ['(a, b, c)'], result
"}}}
"{{{ deoplete
Execute (func()):
let completed_item = {'info': 'func()', 'word': 'Scan('}
let result = cm_parser#go#parameters(completed_item)
AssertEqual ['()'], result
Execute (func(a)):
let completed_item = {'info': 'func(a)', 'word': 'Scan('}
let result = cm_parser#go#parameters(completed_item)
AssertEqual ['(a)'], result
Execute (func(a int)):
let completed_item = {'info': 'func(a int)', 'word': 'Scan('}
let result = cm_parser#go#parameters(completed_item)
AssertEqual ['(a)'], result
Execute (func(a net.Conn)):
let completed_item = {'info': 'func(a net.Conn)', 'word': 'Scan('}
let result = cm_parser#go#parameters(completed_item)
AssertEqual ['(a)'], result
Execute (func(a net.Conn, b, c int)):
let completed_item = {'info': 'func(a net.Conn, b, c int)', 'word': 'Scan('}
let result = cm_parser#go#parameters(completed_item)
AssertEqual ['(a, b, c)'], result
Execute (func(a net.Conn, b, c int) error):
let completed_item = {'info': 'func(a net.Conn, b, c int) error', 'word': 'Scan('}
let result = cm_parser#go#parameters(completed_item)
AssertEqual ['(a, b, c)'], result
Execute (func(a net.Conn, b, c int) (int, error)):
let completed_item = {'info': 'func(a net.Conn, b, c int) (int, error)', 'word': 'Scan('}
let result = cm_parser#go#parameters(completed_item)
AssertEqual ['(a, b, c)'], result
Execute (func(a net.Conn, b, c int) (a int, err error)):
let completed_item = {'info': 'func(a net.Conn, b, c int) (a int, err error)', 'word': 'Scan('}
let result = cm_parser#go#parameters(completed_item)
AssertEqual ['(a, b, c)'], result
Execute (func(a net.Conn, b func()int, c int) (a int, err error)):
let completed_item = {'info': 'func fun(a net.Conn, b func()int, c int) (a int, err error)', 'word': 'fun('}
let result = cm_parser#go#parameters(completed_item)
AssertEqual ['(a, b, c)'], result
Execute (func(a net.Conn, b func() int, c int) (a int, err error)):
let completed_item = {'info': 'func fun(a net.Conn, b func() int, c int) (a int, err error)', 'word': 'func('}
let result = cm_parser#go#parameters(completed_item)
AssertEqual ['(a, b, c)'], result
Execute (func(a net.Conn, b func(a int) int, c int) (a int, err error)):
let completed_item = {'info': 'func fun(a net.Conn, b func(a int) int, c int) (a int, err error)', 'word': 'func('}
let result = cm_parser#go#parameters(completed_item)
AssertEqual ['(a, b, c)'], result
Execute (func(a net.Conn, b func(a int), c int) (a int, err error)):
let completed_item = {'info': 'func fun(a net.Conn, b func(a int), c int) (a int, err error)', 'word': 'func('}
let result = cm_parser#go#parameters(completed_item)
AssertEqual ['(a, b, c)'], result
Execute (func(a net.Conn, b func(a func(a int) float) string, c int) (a int, err error)):
let completed_item = {'info': 'func fun(a net.Conn, b func(a func(a int) float) string, c int) (a int, err error)', 'word': 'func('}
let result = cm_parser#go#parameters(completed_item)
AssertEqual ['(a, b, c)'], result
"}}}

View File

@ -0,0 +1,153 @@
Before:
smap <m-n> <Plug>(complete_parameter#goto_next_parameter)
imap <m-n> <Plug>(complete_parameter#goto_next_parameter)
nmap <m-n> <Plug>(complete_parameter#goto_next_parameter)
smap <m-p> <Plug>(complete_parameter#goto_previous_parameter)
imap <m-p> <Plug>(complete_parameter#goto_previous_parameter)
nmap <m-p> <Plug>(complete_parameter#goto_previous_parameter)
"{{{ forward
Given go(no jump):
fmt.Printf
Do:
1gg5|\<m-n>
Then:
AssertEqual 'n', mode()
let col = col('.')
AssertEqual 5, col
Given go(goto end):
fmt.Printf()
Do:
1gg5|\<m-n>
Then:
AssertEqual 'n', mode()
let col = col('.')
AssertEqual 5, col
Given go(fmt.Printf(format, a), 10, goto format):
fmt.Printf(format, a)
Do:
1gg10|\<m-n>
Then:
AssertEqual 'n', mode()
let start = col('.')
AssertEqual 10, start
Given go(fmt.Printf(format, a), 11, goto format):
fmt.Printf(format, a)
Do:
1gg11|\<m-n>
Then:
AssertEqual 's', mode()
let start = col('v')
AssertEqual 12, start
let end = col('.')
AssertEqual 17, end
Given go(fmt.Printf(format, a), 12, goto a):
fmt.Printf(format, a)
Do:
1gg12|\<m-n>
Then:
AssertEqual 's', mode()
let start = col('v')
AssertEqual 20, start
let end = col('.')
AssertEqual 20, end
Given go(fmt.Printf(format, a), 20, goto end):
fmt.Printf(format, a)
Do:
1gg20|\<m-n>
Then:
AssertEqual 'n', mode()
let end = col('.')
AssertEqual 21, end
"}}}
"{{{ backward
Given go(no jump):
fmt.Printf
Do:
1gg5|\<m-p>
Then:
AssertEqual 'n', mode()
let col = col('.')
AssertEqual 5, col
Given go(goto end):
fmt.Printf()
Do:
1gg12|\<m-p>
Then:
AssertEqual 'n', mode()
let col = col('.')
AssertEqual 12, col
Given go(fmt.Printf(format, a), 21, goto a):
fmt.Printf(format, a)
Do:
1gg21|\<m-p>
Then:
AssertEqual 's', mode()
let start = col('v')
AssertEqual 20, start
let end = col('.')
AssertEqual 20, end
Given go(fmt.Printf(format, a), 20, goto format):
fmt.Printf(format, a)
Do:
1gg20|\<m-p>
Then:
AssertEqual 's', mode()
let start = col('v')
AssertEqual 12, start
let end = col('.')
AssertEqual 17, end
Given go(fmt.Printf(format, a), 12, no jump):
fmt.Printf(format, a)
Do:
1gg12|\<m-p>
Then:
AssertEqual 'n', mode()
let end = col('.')
AssertEqual 12, end
Given javascript(a.fun({format, a}), select {}, jump to format):
a.fun({format, a})
Do:
1gg7|v10l\<c-g>\<m-n>
Then:
AssertEqual 's', mode()
let start = col('v')
AssertEqual 8, start
let end = col('.')
AssertEqual 13, end
"}}}

View File

@ -0,0 +1,100 @@
"{{{ycm
Execute (error menu):
let completed_item = {'menu': 'number'}
let result = cm_parser#javascript#parameters(completed_item)
AssertEqual [], result
Execute (fn()):
let completed_item = {'menu': 'fn()'}
let result = cm_parser#javascript#parameters(completed_item)
AssertEqual ['()'], result
Execute (fn(other: [?])):
let completed_item = {'menu': 'fn(other: [?])'}
let result = cm_parser#javascript#parameters(completed_item)
AssertEqual ['(other)'], result
Execute (fn(other?: string) -> string):
let completed_item = {'menu': 'fn(other?: string) -> string'}
let result = cm_parser#javascript#parameters(completed_item)
AssertEqual ['(other)'], result
Execute (fn(other: ?) -> string):
let completed_item = {'menu': 'fn(other: ?) -> string'}
let result = cm_parser#javascript#parameters(completed_item)
AssertEqual ['(other)'], result
Execute (fn(test: fn(elt: ?, i: number, array: Array) -> bool, context?: ?) -> bool):
let completed_item = {'menu': 'fn(test: fn(elt: ?, i: number, array: Array) -> bool, context?: ?) -> bool'}
let result = cm_parser#javascript#parameters(completed_item)
AssertEqual ['(test, context)'], result
Execute (fn(test: {elt: string, i: number, array: Array}, context?: ?) -> bool):
let completed_item = {'menu': 'fn(test: fn(elt: ?, i: number, array: Array) -> bool, context?: ?) -> bool'}
let result = cm_parser#javascript#parameters(completed_item)
AssertEqual ['(test, context)'], result
Execute (fn(options: {compressible: bool, extensions: [?], register: ?, source: string, type: string})):
let completed_item = {'menu': 'fn(options: {compressible: bool, extensions: [?], register: ?, source: string, type: string})'}
let result = cm_parser#javascript#parameters(completed_item)
AssertEqual ['({compressible, extensions, register, source, type})'], result
Execute (fn({compressible, extensions, register, source, type}: {compressible: bool, extensions: [?], register: ?, source: string, type: string})):
let completed_item = {'menu': 'fn(options: {compressible: bool, extensions: [?], register: ?, source: string, type: string})'}
let result = cm_parser#javascript#parameters(completed_item)
AssertEqual ['({compressible, extensions, register, source, type})'], result
Execute (add(, omni):
let completed_item = {'word': 'add(', 'menu': 'a, b', 'info': '', 'kind': 'f', 'abbr': ''}
let result = cm_parser#javascript#parameters(completed_item)
AssertEqual ['(a, b)'], result
"}}}
"{{{ deoplete
Execute (error menu):
let completed_item = {"info": "number"}
let result = cm_parser#javascript#parameters(completed_item)
AssertEqual [], result
Execute (fn()):
let completed_item = {"info": "fn()\nfsaf"}
let result = cm_parser#javascript#parameters(completed_item)
AssertEqual ["()"], result
Execute (fn(other: [?])):
let completed_item = {"info": "fn(other: [?]\n)->faf"}
let result = cm_parser#javascript#parameters(completed_item)
AssertEqual ["(other)"], result
Execute (fn(other?: string) -> string):
let completed_item = {"info": "fn(other?: string\n) -> string"}
let result = cm_parser#javascript#parameters(completed_item)
AssertEqual ["(other)"], result
Execute (fn(other: ?) -> string):
let completed_item = {"info": "fn(other: ?) -> string"}
let result = cm_parser#javascript#parameters(completed_item)
AssertEqual ["(other)"], result
Execute (fn(test: fn(elt: ?, i: number, array: Array) -> bool, context?: ?) -> bool):
let completed_item = {"info": "fn(test: fn(elt: ?, i: number, array: Array) -> bool, \ncontext?: ?) -> bool"}
let result = cm_parser#javascript#parameters(completed_item)
AssertEqual ["(test, context)"], result
Execute (fn(test: {elt: number, i: number, array: Array}, context?: ?) -> bool):
let completed_item = {"info": "fn(test: fn(elt: ?, i: number, array: Array) -> bool, \ncontext?: ?) -> bool"}
let result = cm_parser#javascript#parameters(completed_item)
AssertEqual ["(test, context)"], result
Execute (fn(options: {compressible: bool, extensions: [?], register: ?, source: string, type: string})):
let completed_item = {'info': 'fn(options: {compressible: bool, extensions: [?], register: ?, source: string, type: string})'}
let result = cm_parser#javascript#parameters(completed_item)
AssertEqual ['({compressible, extensions, register, source, type})'], result
Execute (fn({compressible, extensions, register, source, type}: {compressible: bool, extensions: [?], register: ?, source: string, type: string})):
let completed_item = {'info': 'fn(options: {compressible: bool, extensions: [?], register: ?, source: string, type: string})'}
let result = cm_parser#javascript#parameters(completed_item)
AssertEqual ['({compressible, extensions, register, source, type})'], result
"}}}

View File

@ -0,0 +1,35 @@
Given go(1):
a
Execute:
call cursor(1, 1)
AssertEqual 0, cmp#jumpable(1)
AssertEqual 0, cmp#jumpable(0)
Given go(2):
func a()
Execute:
call cursor(1, 6)
AssertEqual 0, cmp#jumpable(1)
AssertEqual 1, cmp#jumpable(0)
call cursor(1, 7)
AssertEqual 1, cmp#jumpable(1)
AssertEqual 1, cmp#jumpable(0)
Given go(3):
func a(a)
Execute:
call cursor(1, 8)
AssertEqual 1, cmp#jumpable(1)
AssertEqual 1, cmp#jumpable(0)
Given go(3):
func a(a, b)
Execute:
call cursor(1, 8)
AssertEqual 1, cmp#jumpable(1)
AssertEqual 1, cmp#jumpable(0)

View File

@ -0,0 +1,60 @@
Execute (items empty):
let result = cmp#next_overload_content([], 0, '', [0, 1, 2, 0], 1)
AssertEqual [0], result
Execute (1 item):
let items = ['()']
let current_index = 0
let current_line = 'hello()'
let complete_pos = [1, 6]
let result = cmp#next_overload_content(items, current_index, current_line, complete_pos, 1)
AssertEqual [0], result
Execute (0->1):
let items = ['()', '(a)', '(b)']
let current_index = 0
let current_line = 'hello()'
let complete_pos = [1, 6]
let result = cmp#next_overload_content(items, current_index, current_line, complete_pos, 1)
AssertEqual [1, '(a)', 1, 2], result
Execute (1->2):
let items = ['()', '(a)', '(b)']
let current_index = 1
let current_line = 'hello(a)'
let complete_pos = [1, 6]
let result = cmp#next_overload_content(items, current_index, current_line, complete_pos, 1)
AssertEqual [1, '(b)', 2, 3], result
Execute (2->0):
let items = ['()', '(a)', '(b)']
let current_index = 2
let current_line = 'hello(b)'
let complete_pos = [1, 6]
let result = cmp#next_overload_content(items, current_index, current_line, complete_pos, 1)
AssertEqual [1, '()', 0, 3], result
Execute (0->2):
let items = ['()', '(a)', '(b)']
let current_index = 0
let current_line = 'hello()'
let complete_pos = [1, 6]
let result = cmp#next_overload_content(items, current_index, current_line, complete_pos, 0)
AssertEqual [1, '(b)', 2, 2], result
Execute (2->1):
let items = ['()', '(a)', '(b)']
let current_index = 2
let current_line = 'hello(b)'
let complete_pos = [1, 6]
let result = cmp#next_overload_content(items, current_index, current_line, complete_pos, 0)
AssertEqual [1, '(a)', 1, 3], result
Execute (1->0):
let items = ['()', '(a)', '(b)']
let current_index = 1
let current_line = 'hello(a)'
let complete_pos = [1, 6]
let result = cmp#next_overload_content(items, current_index, current_line, complete_pos, 0)
AssertEqual [1, '()', 0, 3], result

View File

@ -0,0 +1,487 @@
Before:
let g:complete_parameter_log_level = 5
call cmp#init()
" {{{ parameter checker
Execute (empty content):
let result = cmp#parameter_position('', 0, ',', '(', ')', 1)
AssertEqual [0, 0], result
Execute (zero current_col):
let result = cmp#parameter_position('hello', 0, ',', '(', ')', 1)
AssertEqual [0, 0], result
Execute (empty delim):
let result = cmp#parameter_position('hello', 1, '', '(', ')', 1)
AssertEqual [0, 0], result
Execute (empty border_begin):
let result = cmp#parameter_position('hello', 1, ',', '', ')', 1)
AssertEqual [0, 0], result
Execute (empty border_end):
let result = cmp#parameter_position('hello', 1, ',', '(', '', 1)
AssertEqual [0, 0], result
Execute (empty border_end):
let result = cmp#parameter_position('hello', 1, ',', '(', ')', 0)
AssertEqual [0, 0], result
Execute (error cul):
let result = cmp#parameter_position('hello', 6, ',', '(', ')', 1)
AssertEqual [0, 0], result
"}}}
" no parameter {{{
Execute (has no paramameter):
let result = cmp#parameter_position('hello', 1, ',', '(', ')', 1)
AssertEqual [0, 0], result
Execute (has no paramameter backword):
let result = cmp#parameter_position('hello', 2, ',', ')', '(', -1)
AssertEqual [0, 0], result
" }}}
" zero parameter {{{
Execute (hello(), 1):
let result = cmp#parameter_position('hello()', 1, ',', '(', ')', 1)
AssertEqual [0, 0], result
Execute (hello(), 1, -1):
let result = cmp#parameter_position('hello()', 5, ',', ')', '(', -1)
AssertEqual [0, 0], result
Execute (hello(), 6):
let result = cmp#parameter_position('hello()', 6, ',', '(', ')', 1)
AssertEqual [7, 7], result
Execute (hello(), 6, -1):
let result = cmp#parameter_position('hello()', 6, ',', ')', '(', -1)
AssertEqual [6, 6], result
Execute (hello(), 7):
let result = cmp#parameter_position('hello()', 7, ',', '(', ')', 1)
AssertEqual [7, 7], result
Execute (hello(), 7, -1):
let result = cmp#parameter_position('hello()', 7, ',', ')', '(', -1)
AssertEqual [6, 6], result
Execute (hello( ), 5):
let result = cmp#parameter_position('hello( )', 5, ',', '(', ')', 1)
AssertEqual [0, 0], result
Execute (hello() , 8, -1):
let result = cmp#parameter_position('hello() ', 8, ',', ')', '(', -1)
AssertEqual [0, 0], result
Execute (hello( ), 6):
let result = cmp#parameter_position('hello( )', 6, ',', '(', ')', 1)
AssertEqual [8, 8], result
Execute (hello( ), 7):
let result = cmp#parameter_position('hello( )', 7, ',', '(', ')', 1)
AssertEqual [8, 8], result
Execute (hello( ), 8):
let result = cmp#parameter_position('hello( )', 8, ',', '(', ')', 1)
AssertEqual [8, 8], result
" }}}
" one parameter {{{
Execute (hello(a), 5):
let result = cmp#parameter_position('hello(a)', 5, ',', '(', ')', 1)
AssertEqual [0, 0], result
Execute (hello(a), 8, -1):
let result = cmp#parameter_position('hello(a)', 8, ',', ')', '(', -1)
AssertEqual [7, 8], result
Execute (hello(a), 6):
let result = cmp#parameter_position('hello(a)', 6, ',', '(', ')', 1)
AssertEqual [7, 8], result
Execute (hello(a) , 9, -1):
let result = cmp#parameter_position('hello(a) ', 9, ',', ')', '(', -1)
AssertEqual [0, 0], result
Execute (hello(a), 7):
let result = cmp#parameter_position('hello(a)', 7, ',', '(', ')', 1)
AssertEqual [8, 8], result
Execute (hello( a), 5):
let result = cmp#parameter_position('hello( a)', 5, ',', '(', ')', 1)
AssertEqual [0, 0], result
Execute (hello( a) , 9, -1):
let result = cmp#parameter_position('hello( a) ', 9, ',', ')', '(', -1)
AssertEqual [8, 9], result
Execute (hello( a), 6):
let result = cmp#parameter_position('hello( a)', 6, ',', '(', ')', 1)
AssertEqual [8, 9], result
Execute (hello( a), 7):
let result = cmp#parameter_position('hello( a)', 7, ',', '(', ')', 1)
AssertEqual [9, 9], result
Execute (hello( a), 8):
let result = cmp#parameter_position('hello( a)', 8, ',', '(', ')', 1)
AssertEqual [9, 9], result
Execute (hello( a), 9):
let result = cmp#parameter_position('hello( a)', 9, ',', '(', ')', 1)
AssertEqual [9, 9], result
Execute (hello( a ), 5):
let result = cmp#parameter_position('hello( a )', 5, ',', '(', ')', 1)
AssertEqual [0, 0], result
Execute (hello( a ) , 10, -1):
let result = cmp#parameter_position('hello( a ) ', 10, ',', ')', '(', -1)
AssertEqual [8, 9], result
Execute (hello( a ), 6):
let result = cmp#parameter_position('hello( a )', 6, ',', '(', ')', 1)
AssertEqual [8, 9], result
Execute (hello( a ) , 9, -1):
let result = cmp#parameter_position('hello( a ) ', 9, ',', ')', '(', -1)
AssertEqual [6, 6], result
Execute (hello( a ), 7):
let result = cmp#parameter_position('hello( a )', 7, ',', '(', ')', 1)
AssertEqual [10, 10], result
Execute (hello(aa), 5):
let result = cmp#parameter_position('hello(aa)', 5, ',', '(', ')', 1)
let g:complete_parameter_jump_in_scope = 0
AssertEqual [0, 0], result
Execute (hello(aa) , 9, -1):
let result = cmp#parameter_position('hello(aa) ', 9, ',', ')', '(', -1)
AssertEqual [7, 9], result
Execute (hello(aa), 6):
let result = cmp#parameter_position('hello(aa)', 6, ',', '(', ')', 1)
AssertEqual [7, 9], result
Execute (hello(aa), 7):
let result = cmp#parameter_position('hello(aa)', 7, ',', '(', ')', 1)
AssertEqual [9, 9], result
" }}}
" 2 parameter {{{
Execute (hello(aa, bb), 5):
let result = cmp#parameter_position('hello(aa, bb)', 5, ',', '(', ')', 1)
AssertEqual [0, 0], result
Execute (hello(aa, bb), 13, -1):
let result = cmp#parameter_position('hello(aa, bb)', 13, ',', ')', '(', -1)
AssertEqual [11, 13], result
Execute (hello(aa, bb), 6):
let result = cmp#parameter_position('hello(aa, bb)', 6, ',', '(', ')', 1)
AssertEqual [7, 9], result
Execute (hello(aa, bb), 11, -1):
let result = cmp#parameter_position('hello(aa, bb)', 11, ',', ')', '(', -1)
AssertEqual [7, 9], result
Execute (hello(aa, bb), 7):
let result = cmp#parameter_position('hello(aa, bb)', 7, ',', '(', ')', 1)
AssertEqual [11, 13], result
Execute (hello(aa, bb), 9):
let result = cmp#parameter_position('hello(aa, bb)', 9, ',', '(', ')', 1)
AssertEqual [11, 13], result
Execute (hello(aa, bb), 10):
let result = cmp#parameter_position('hello(aa, bb)', 10, ',', '(', ')', 1)
AssertEqual [13, 13], result
" }}}
" 3 parameter {{{
Execute (hello(aa, bb, cccc), 7):
let result = cmp#parameter_position('hello(aa, bb, cccc)', 7, ',', '(', ')', 1)
AssertEqual [11, 13], result
Execute (hello(aa, bb, cccc), 19, -1):
let result = cmp#parameter_position('hello(aa, bb, cccc)', 19, ',', ')', '(', -1)
AssertEqual [15, 19], result
Execute (hello(aa, bb, cccc), 11):
let result = cmp#parameter_position('hello(aa, bb, cccc)', 11, ',', '(', ')', 1)
AssertEqual [15, 19], result
Execute (hello(aa, bb, cccc), 15, -1):
let result = cmp#parameter_position('hello(aa, bb, cccc)', 15, ',', ')', '(', -1)
AssertEqual [11, 13], result
Execute (hello(aa, bb, cccc), 15):
let result = cmp#parameter_position('hello(aa, bb, cccc)', 15, ',', '(', ')', 1)
AssertEqual [19, 19], result
" }}}
" param with () {{{
Execute (hello(foo()), 1):
let result = cmp#parameter_position('hello(foo())', 1, ',', '(', ')', 1)
AssertEqual [0, 0], result
Execute (hello(foo()), 12, -1):
let result = cmp#parameter_position('hello(foo())', 12, ',', ')', '(', -1)
AssertEqual [7, 12], result
Execute (hello(foo()), 6):
let result = cmp#parameter_position('hello(foo())', 6, ',', '(', ')', 1)
AssertEqual [7, 12], result
Execute (hello(foo()), 11, -1):
let result = cmp#parameter_position('hello(foo())', 11, ',', ')', '(', -1)
AssertEqual [10, 10], result
Execute (hello(foo()), 7):
let result = cmp#parameter_position('hello(foo())', 7, ',', '(', ')', 1)
AssertEqual [11, 11], result
Execute (hello(foo()), 10, -1):
let result = cmp#parameter_position('hello(foo())', 10, ',', ')', '(', -1)
AssertEqual [6, 6], result
Execute (hello(foo()), 11):
let result = cmp#parameter_position('hello(foo())', 11, ',', '(', ')', 1)
AssertEqual [12, 12], result
Execute (hello(foo(bar)), 6):
let result = cmp#parameter_position('hello(foo(bar))', 6, ',', '(', ')', 1)
AssertEqual [7, 15], result
Execute (hello(foo(bar)), 15, -1):
let result = cmp#parameter_position('hello(foo(bar))', 15, ',', ')', '(', -1)
AssertEqual [7, 15], result
Execute (hello(foo(bar)), 7):
let result = cmp#parameter_position('hello(foo(bar))', 7, ',', '(', ')', 1)
AssertEqual [11, 14], result
Execute (hello(foo(bar)), 13, -1):
let result = cmp#parameter_position('hello(foo(bar))', 13, ',', ')', '(', -1)
AssertEqual [6, 6], result
Execute (hello(foo(bar)), 11):
let result = cmp#parameter_position('hello(foo(bar))', 11, ',', '(', ')', 1)
AssertEqual [15, 15], result
Execute (hello(a, foo(bar)), 7):
let result = cmp#parameter_position('hello(a, foo(bar))', 7, ',', '(', ')', 1)
AssertEqual [10, 18], result
Execute (hello(a, foo(bar)), 13, -1):
let result = cmp#parameter_position('hello(a, foo(bar))', 13, ',', ')', '(', -1)
AssertEqual [7, 8], result
Execute (hello(a, foo(bar)), 8):
let result = cmp#parameter_position('hello(a, foo(bar))', 8, ',', '(', ')', 1)
AssertEqual [10, 18], result
Execute (hello(a, foo(bar)), 9):
let result = cmp#parameter_position('hello(a, foo(bar))', 9, ',', '(', ')', 1)
AssertEqual [14, 17], result
Execute (hello(a, foo(bar), b), 14):
let result = cmp#parameter_position('hello(a, foo(bar), b)', 14, ',', '(', ')', 1)
AssertEqual [20, 21], result
Execute (hello(a, foo(bar), b), 7):
let result = cmp#parameter_position('hello(a, foo(bar), b)', 7, ',', '(', ')', 1)
AssertEqual [10, 18], result
Execute (hello(a, foo(bar, world), b), 7):
let result = cmp#parameter_position('hello(a, foo(bar, world), b)', 7, ',', '(', ')', 1)
AssertEqual [10, 25], result
Execute (hello(a, foo(bar, world)(g, h), b), 7):
let result = cmp#parameter_position('hello(a, foo(bar, world)(g, h), b)', 7, ',', '(', ')', 1)
AssertEqual [10, 31], result
Execute (hello(a, foo(bar, world)(g, h)(i, j), b), 7):
let result = cmp#parameter_position('hello(a, foo(bar, world)(g, h)(i, j), b)', 7, ',', '(', ')', 1)
AssertEqual [10, 37], result
" }}}
" param has quote {{{
Execute (hello(aa, "(", ccc), 7):
let result = cmp#parameter_position('hello(aa, "(", ccc)', 7, ',', '(', ')', 1)
AssertEqual [11, 14], result
Execute (hello(aa, "(", ccc), 16, -1):
let result = cmp#parameter_position('hello(aa, "(", ccc)', 16, ',', ')', '(', -1)
AssertEqual [11, 14], result
Execute (hello(aa, "(", ccc), 10):
let result = cmp#parameter_position('hello(aa, "(", ccc)', 10, ',', '(', ')', 1)
AssertEqual [16, 19], result
Execute (hello(aa, "(", ccc), 10, -1):
let result = cmp#parameter_position('hello(aa, "(", ccc)', 10, ',', ')', '(', -1)
AssertEqual [7, 9], result
Execute (hello(aa, "(", ccc), 11):
let result = cmp#parameter_position('hello(aa, "(", ccc)', 11, ',', '(', ')', 1)
AssertEqual [16, 19], result
Execute (hello(aa, "(", ccc), 12):
let result = cmp#parameter_position('hello(aa, "(", ccc)', 12, ',', '(', ')', 1)
AssertEqual [16, 19], result
Execute (hello(aa, "(", ccc), 13):
let result = cmp#parameter_position('hello(aa, "(", ccc)', 13, ',', '(', ')', 1)
AssertEqual [16, 19], result
Execute (hello(aa, "(\"", ccc)):
let result = cmp#parameter_position('hello(aa, "(\"", ccc)', 7, ',', '(', ')', 1)
AssertEqual [11, 16], result
Execute (hello(aa, "(\"", ccc), 18, -1):
let result = cmp#parameter_position('hello(aa, "(\"", ccc)', 18, ',', ')', '(', -1)
AssertEqual [11, 16], result
Execute (hello(`a""a`, "(\"", "ccc", d), 24):
let result = cmp#parameter_position('hello(`a""a`, "(\"", "ccc", d)', 24, ',', '(', ')', 1)
AssertEqual [29, 30], result
Execute (hello(`a"'a`, "(\"", "ccc", d), 24):
let result = cmp#parameter_position('hello(`a"''a`, "(\"", "ccc", d)', 24, ',', '(', ')', 1)
AssertEqual [29, 30], result
Execute (fmt.Fscanf("%s %s", "hello", "world"), jump to hello):
let i = 12
while i <= 19
let result = cmp#parameter_position('fmt.Fscanf("%s %s", "hello", "world")', i, ',', '(', ')', 1)
AssertEqual [21, 28], result
let i += 1
endwhile
Execute (fmt.Fscanf("%s %s", "hello", "world"), jump to world):
let i = 21
while i <= 28
let result = cmp#parameter_position('fmt.Fscanf("%s %s", "hello", "world")', i, ',', '(', ')', 1)
AssertEqual [30, 37], result
let i += 1
endwhile
Execute (fmt.Fscanf("%s %s", "hello", "world"), jump to end):
let i = 30
while i <= 36
let result = cmp#parameter_position('fmt.Fscanf("%s %s", "hello", "world")', i, ',', '(', ')', 1)
AssertEqual [37, 37], result
let i += 1
endwhile
Execute (fmt.Fscanf("%s %s", "hello", "world"), jump to world, -1):
let result = cmp#parameter_position('fmt.Fscanf("%s %s", "hello", "world")', 37, ',', ')', '(', -1)
AssertEqual [30, 37], result
Execute (fmt.Fscanf("%s %s", "hello", "world"), jump to hello, -1):
let i = 30
while i < 37
let result = cmp#parameter_position('fmt.Fscanf("%s %s", "hello", "world")', i, ',', ')', '(', -1)
AssertEqual [21, 28], result
let i += 1
endwhile
Execute (fmt.Fscanf("%s %s", "hello", "world"), jump to "%s %s", -1):
let i = 21
while i < 28
let result = cmp#parameter_position('fmt.Fscanf("%s %s", "hello", "world")', i, ',', ')', '(', -1)
AssertEqual [12, 19], result
let i += 1
endwhile
"}}}
" {{{param has <>
Execute (hello<a, b>, 1):
let result = cmp#parameter_position('hello<a, b>', 1, ',', "(<", ")>", 1)
AssertEqual [0, 0], result
Execute (hello<a, b>, 7):
let result = cmp#parameter_position('hello<a, b>', 7, ',', "(<", ")>", 1)
AssertEqual [10, 11], result
Execute (hello<a, b>, 7):
let result = cmp#parameter_position('hello<a, b>', 7, ',', "(<", ")>", 1)
AssertEqual [10, 11], result
Execute (hello<a, b>(c, d), 10):
let result = cmp#parameter_position('hello<a, b>(c, d)', 10, ',', "(<", ")>", 1)
AssertEqual [13, 14], result
Execute (hello<a, b>(c, d, func<e, f>(g, h, i))), 16):
let result = cmp#parameter_position('hello<a, b>(c, d, func<e, f>(g, h, i)))', 16, ',', "(<", ")>", 1)
AssertEqual [19, 38], result
"}}}
"{{{ border check
Execute(border left):
let result = cmp#parameter_position('hello(a, b)', 5, ',', '(<', ')>', 1)
AssertEqual [0, 0], result
Execute(border ():
let result = cmp#parameter_position('hello(a, b)', 6, ',', '(<', ')>', 1)
AssertEqual [7, 8], result
Execute(border )):
let result = cmp#parameter_position('hello(a, b)', 11, ',', '(<', ')>', 1)
AssertEqual [11, 11], result
Execute(border ), -1):
let result = cmp#parameter_position('hello(a, b)', 11, ',', ')>', '(<', -1)
AssertEqual [10, 11], result
Execute(border ) , -1):
let result = cmp#parameter_position('hello(a, b) ', 12, ',', ')>', '(<', -1)
AssertEqual [0, 0], result
" }}}
"{{{ has =
Execute(=, 1, test0):
let result = cmp#parameter_position('hello(a=1, b=2)', 7, ',', '(', ')', 1)
AssertEqual [9, 10], result
Execute(=, 1, test1):
let result = cmp#parameter_position('hello(a=1, b=2)', 8, ',', '(', ')', 1)
AssertEqual [9, 10], result
Execute(=, 1, test2):
let result = cmp#parameter_position('hello(a=1, b=2)', 9, ',', '(', ')', 1)
AssertEqual [14, 15], result
Execute(=, 1, test3):
let result = cmp#parameter_position('hello(a=1, b=(c=1, d=2))', 9, ',', '(', ')', 1)
AssertEqual [14, 24], result
Execute(=, -1, test0):
let result = cmp#parameter_position('hello(a=1, b=2)', 14, ',', ')', '(', -1)
AssertEqual [9, 10], result
Execute(=, -1, test1):
let result = cmp#parameter_position('hello(a=1, b=2)', 11, ',', ')', '(', -1)
AssertEqual [9, 10], result
Execute(=, -1, test2):
let result = cmp#parameter_position('hello(a=1, b=2)', 10, ',', ')', '(', -1)
AssertEqual [9, 10], result
Execute(=, -1, test3):
let result = cmp#parameter_position('hello(a=1, b=(c=1, d=2))', 24, ',', ')', '(', -1)
AssertEqual [14, 24], result
"}}}
" < > match
Execute(>):
let result = cmp#parameter_position('a->hello(a)', 10, ',', ')>', '(<', -1)
AssertEqual [9, 9], result
Execute(<):
let result = cmp#parameter_position('hello(a) < hello(b)', 9, ',', '(<', ')>', 1)
AssertEqual [0, 0], result

View File

@ -0,0 +1,55 @@
Execute:
let parser_str = globpath(&rtp, 'cm_parser/*.vim')
let parsers = split(parser_str, '\n')
for parser in parsers
let ft = fnamemodify(parser, ':t:r')
try
let ftfunc = cmp#new_ftfunc(ft)
Assert cmp#filetype_func_check(ftfunc)
catch
Assert 0
endtry
endfor
Execute (check parameter return,(),(,)):
let parameter = '()'
let begin = '('
let end = ')'
Assert cmp#check_parameter_return(parameter, begin, end)
Execute (check parameter return,(a),(,)):
let parameter = '(a)'
let begin = '('
let end = ')'
Execute (check parameter return,(a),(<,)>):
Assert cmp#check_parameter_return(parameter, begin, end)
let parameter = '(a)'
let begin = '(<'
let end = ')>'
Assert cmp#check_parameter_return(parameter, begin, end)
Execute (check parameter return,,(,)):
let parameter = ''
let begin = '('
let end = ')'
Assert !cmp#check_parameter_return(parameter, begin, end)
Execute (check parameter return,(,(,)):
let parameter = '('
let begin = '('
let end = ')'
Assert !cmp#check_parameter_return(parameter, begin, end)
Execute (check parameter return,(a,(,)):
let parameter = '(a'
let begin = '('
let end = ')'
Assert !cmp#check_parameter_return(parameter, begin, end)
Execute (check parameter return,a),(,)):
let parameter = '(a'
let begin = '('
let end = ')'
Assert !cmp#check_parameter_return(parameter, begin, end)

View File

@ -0,0 +1,281 @@
Before:
let g:complete_parameter_py_keep_value = 0
let g:complete_parameter_py_remove_default = 0
" {{{ ycm
Execute (error menu):
let completed_item = {'menu': 'module:func', 'info': 'func()'}
let result = cm_parser#python#parameters(completed_item)
AssertEqual [], result
Execute (error info):
let completed_item = {'menu': 'function:func', 'info': ''}
let result = cm_parser#python#parameters(completed_item)
AssertEqual [], result
Execute (foo()):
let completed_item = {'menu': 'function:foo', 'info': "foo()\nfoo function"}
let result = cm_parser#python#parameters(completed_item)
AssertEqual ['()'], result
Execute (foo() -> int):
let completed_item = {'menu': 'function:foo', 'info': "foo() -> int \nfoo function"}
let result = cm_parser#python#parameters(completed_item)
AssertEqual ['()'], result
Execute (foo(a) -> int):
let completed_item = {'menu': 'function:foo', 'info': "foo(a) -> int \nfoo function"}
let result = cm_parser#python#parameters(completed_item)
AssertEqual ['(a)'], result
Execute (foo(a, b) -> int):
let completed_item = {'menu': 'function:foo', 'info': "foo(a, b) -> int \nfoo function"}
let result = cm_parser#python#parameters(completed_item)
AssertEqual ['(a, b)'], result
Execute (foo(a, b = 1) -> int):
let completed_item = {'menu': 'function:foo', 'info': "foo(a, b = 1) -> int \nfoo function"}
let result = cm_parser#python#parameters(completed_item)
AssertEqual ['(a, b)'], result
Execute (foo(a, b = []) -> int):
let completed_item = {'menu': 'function:foo', 'info': "foo(a, b = []) -> int \nfoo function"}
let result = cm_parser#python#parameters(completed_item)
AssertEqual ['(a, b)'], result
Execute (foo(a, b = []) -> (int, True):
let completed_item = {'menu': 'function:foo', 'info': "foo(a, b = []) -> (int, True) \nfoo function"}
let result = cm_parser#python#parameters(completed_item)
AssertEqual ['(a, b)'], result
Execute (add(a, b), omni):
let completed_item = {'word': '(', 'menu': '', 'info': ' ', 'kind': '', 'abbr': 'add(a,b)'}
let result = cm_parser#python#parameters(completed_item)
AssertEqual ['(a, b)'], result
Execute (remove `[]`):
let g:complete_parameter_py_keep_value = 1
let completed_item = {'word': 'mkdir', 'menu': 'def mkdir', 'info': 'mkdir(path [, mode=0777])^@^@Create a directory.', 'kind': '', 'abbr': ''}
let result = cm_parser#python#parameters(completed_item)
AssertEqual ['(path, mode=0777)'], result
Execute (remove default 1):
let g:complete_parameter_py_keep_value = 0
let g:complete_parameter_py_remove_default = 1
let completed_item = {'word': 'mkdir', 'menu': 'def mkdir', 'info': 'mkdir(path , mode=0777)^@^@Create a directory.', 'kind': '', 'abbr': ''}
let result = cm_parser#python#parameters(completed_item)
AssertEqual ['(path)'], result
let g:complete_parameter_py_remove_default = 0
" interact(self, escape_character=chr(29), input_filter=None,
" output_filter=None)
Execute (interact(self, excape_character=ch(29)):
let completed_item = {'menu': 'function:interact', 'info': "interact(self, escape_character=chr(29), input_filter=None,\noutput_filter=None)"}
let result = cm_parser#python#parameters(completed_item)
AssertEqual ['(escape_character, input_filter, output_filter)'], result
Execute (interact(self, excape_character=ch(29) -> int):
let completed_item = {'menu': 'function:interact', 'info': "interact(self, escape_character=chr(29), input_filter=None,\noutput_filter=None) -> int"}
let result = cm_parser#python#parameters(completed_item)
AssertEqual ['(escape_character, input_filter, output_filter)'], result
Execute (interact(self, excape_character=ch(29) -> (int, int)):
let completed_item = {'menu': 'function:interact', 'info': "interact(self, escape_character=chr(29), input_filter=None,\noutput_filter=None) -> (int, int)"}
let result = cm_parser#python#parameters(completed_item)
AssertEqual ['(escape_character, input_filter, output_filter)'], result
Execute (interact(self, excape_character=ch(29) -> (int, int)):
let g:complete_parameter_py_keep_value = 1
let completed_item = {'menu': 'function:interact', 'info': "interact(self, escape_character=chr(29), input_filter=None,\noutput_filter=None) -> (int, int)"}
let result = cm_parser#python#parameters(completed_item)
AssertEqual ['(escape_character=chr(29), input_filter=None, output_filter=None)'], result
Execute (no parameter):
let completed_item = {'word': 'mkdir', 'menu': 'def mkdir', 'info': 'Create a directory.\n\nif dir_fd is not None, it should be a file descriptor open to a directory,\n and path should be relative; path will then be relative to that directory.\ndir_fd may not be implemented on your platform.\n If it is unavailable, using it will raise a NotImplementedError.\n\nthe mode argument is ignored on Windows.', 'kind': '', 'abbr': ''}
let result = cm_parser#python#parameters(completed_item)
AssertEqual ['()'], result
"}}}
" {{{ def
Execute (error menu):
let completed_item = {'menu': 'module:func', 'info': 'func()'}
let result = cm_parser#python#parameters(completed_item)
AssertEqual [], result
Execute (error info):
let completed_item = {'menu': 'def func', 'info': ''}
let result = cm_parser#python#parameters(completed_item)
AssertEqual [], result
Execute (foo()):
let completed_item = {'menu': 'def foo', 'info': "foo()\nfoo function"}
let result = cm_parser#python#parameters(completed_item)
AssertEqual ['()'], result
Execute (foo() -> int):
let completed_item = {'menu': 'def foo', 'info': "foo() -> int \nfoo function"}
let result = cm_parser#python#parameters(completed_item)
AssertEqual ['()'], result
Execute (foo(a) -> int):
let completed_item = {'menu': 'def foo', 'info': "foo(a) -> int \nfoo function"}
let result = cm_parser#python#parameters(completed_item)
AssertEqual ['(a)'], result
Execute (foo(a, b) -> int):
let completed_item = {'menu': 'def foo', 'info': "foo(a, b) -> int \nfoo function"}
let result = cm_parser#python#parameters(completed_item)
AssertEqual ['(a, b)'], result
Execute (foo(a, b = 1) -> int):
let completed_item = {'menu': 'def foo', 'info': "foo(a, b = 1) -> int \nfoo function"}
let result = cm_parser#python#parameters(completed_item)
AssertEqual ['(a, b)'], result
Execute (foo(a, b = []) -> int):
let completed_item = {'menu': 'def foo', 'info': "foo(a, b = []) -> int \nfoo function"}
let result = cm_parser#python#parameters(completed_item)
AssertEqual ['(a, b)'], result
Execute (foo(a, b = []) -> (int, True):
let completed_item = {'menu': 'def foo', 'info': "foo(a, b = []) -> (int, True) \nfoo function"}
let result = cm_parser#python#parameters(completed_item)
AssertEqual ['(a, b)'], result
Execute (multi line, with self, ', )'):
let completed_item = {'menu': 'def exec_command', 'info': "exec_command( self, command, bufsize=-1,\ntimeout=None, get_pty=False, environment=None, )"}
let result = cm_parser#python#parameters(completed_item)
AssertEqual ['(command, bufsize, timeout, get_pty, environment)'], result
Execute (multi line, with cls, ', )'):
let completed_item = {'menu': 'def exec_command', 'info': "exec_command( cls, command, bufsize=-1,\ntimeout=None, get_pty=False, environment=None, )"}
let result = cm_parser#python#parameters(completed_item)
AssertEqual ['(command, bufsize, timeout, get_pty, environment)'], result
Execute (multi line, ', )'):
let completed_item = {'menu': 'def exec_command', 'info': "exec_command( command, bufsize=-1,\ntimeout=None, get_pty=False, environment=None, )"}
let result = cm_parser#python#parameters(completed_item)
AssertEqual ['(command, bufsize, timeout, get_pty, environment)'], result
Execute (multi line):
let completed_item = {'menu': 'def exec_command', 'info': "exec_command( command, bufsize=-1,\ntimeout=None, get_pty=False, environment=None)"}
let result = cm_parser#python#parameters(completed_item)
AssertEqual ['(command, bufsize, timeout, get_pty, environment)'], result
" interact(self, escape_character=chr(29), input_filter=None,
" output_filter=None)
Execute (interact(self, excape_character=ch(29)):
let completed_item = {'menu': 'def interact', 'info': "interact(self, escape_character=chr(29), input_filter=None,\noutput_filter=None)"}
let result = cm_parser#python#parameters(completed_item)
AssertEqual ['(escape_character, input_filter, output_filter)'], result
Execute (interact(self, excape_character=ch(29) -> int):
let completed_item = {'menu': 'def interact', 'info': "interact(self, escape_character=chr(29), input_filter=None,\noutput_filter=None) -> int"}
let result = cm_parser#python#parameters(completed_item)
AssertEqual ['(escape_character, input_filter, output_filter)'], result
Execute (interact(self, excape_character=ch(29) -> (int, int)):
let completed_item = {'menu': 'def interact', 'info': "interact(self, escape_character=chr(29), input_filter=None,\noutput_filter=None) -> (int, int)"}
let result = cm_parser#python#parameters(completed_item)
AssertEqual ['(escape_character, input_filter, output_filter)'], result
"}}}
" {{{ deoplete
Execute (foo()):
let completed_item = {'word': 'foo(', 'info': "foo()\nfoo function"}
let result = cm_parser#python#parameters(completed_item)
AssertEqual ['()'], result
Execute (foo() -> int):
let completed_item = {'word': 'foo(', 'info': "foo() -> int \nfoo function"}
let result = cm_parser#python#parameters(completed_item)
AssertEqual ['()'], result
Execute (foo(a) -> int):
let completed_item = {'word': 'foo(', 'info': "foo(a) -> int \nfoo function"}
let result = cm_parser#python#parameters(completed_item)
AssertEqual ['(a)'], result
Execute (foo(a, b) -> int):
let completed_item = {'word': 'foo(', 'info': "foo(a, b) -> int \nfoo function"}
let result = cm_parser#python#parameters(completed_item)
AssertEqual ['(a, b)'], result
Execute (foo(a, b = 1) -> int):
let completed_item = {'word': 'foo(', 'info': "foo(a, b = 1) -> int \nfoo function"}
let result = cm_parser#python#parameters(completed_item)
AssertEqual ['(a, b)'], result
Execute (foo(a, b = []) -> int):
let completed_item = {'word': 'foo(', 'info': "foo(a, b = []) -> int \nfoo function"}
let result = cm_parser#python#parameters(completed_item)
AssertEqual ['(a, b)'], result
Execute (foo(a, b = []) -> (int, True):
let completed_item = {'word': 'foo(', 'info': "foo(a, b = []) -> (int, True) \nfoo function"}
let result = cm_parser#python#parameters(completed_item)
AssertEqual ['(a, b)'], result
Execute (multi line, with self, ', )'):
let completed_item = {'word': 'exec_command(', 'info': "exec_command( self, command, bufsize=-1,\ntimeout=None, get_pty=False, environment=None, )"}
let result = cm_parser#python#parameters(completed_item)
AssertEqual ['(command, bufsize, timeout, get_pty, environment)'], result
Execute (multi line, with cls, ', )'):
let completed_item = {'word': 'exec_command(', 'info': "exec_command( cls, command, bufsize=-1,\ntimeout=None, get_pty=False, environment=None, )"}
let result = cm_parser#python#parameters(completed_item)
AssertEqual ['(command, bufsize, timeout, get_pty, environment)'], result
Execute (multi line, ', )'):
let completed_item = {'word': 'exec_command(', 'info': "exec_command( command, bufsize=-1,\ntimeout=None, get_pty=False, environment=None, )"}
let result = cm_parser#python#parameters(completed_item)
AssertEqual ['(command, bufsize, timeout, get_pty, environment)'], result
Execute (multi line):
let completed_item = {'word': 'exec_command(', 'info': "exec_command( command, bufsize=-1,\ntimeout=None, get_pty=False, environment=None)"}
let result = cm_parser#python#parameters(completed_item)
AssertEqual ['(command, bufsize, timeout, get_pty, environment)'], result
" interact(self, escape_character=chr(29), input_filter=None,
" output_filter=None)
Execute (interact(self, excape_character=ch(29)):
let completed_item = {'word': 'interact(', 'menu': 'def interact', 'info': "interact(self, escape_character=chr(29), input_filter=None,\noutput_filter=None)"}
let result = cm_parser#python#parameters(completed_item)
AssertEqual ['(escape_character, input_filter, output_filter)'], result
Execute (interact(self, excape_character=ch(29) -> int):
let completed_item = {'word': 'interact(', 'menu': 'def interact', 'info': "interact(self, escape_character=chr(29), input_filter=None,\noutput_filter=None) -> int"}
let result = cm_parser#python#parameters(completed_item)
AssertEqual ['(escape_character, input_filter, output_filter)'], result
Execute (interact(self, excape_character=ch(29) -> (int, int)):
let completed_item = {'word': 'interact(', 'menu': 'def interact', 'info': "interact(self, escape_character=chr(29), input_filter=None,\noutput_filter=None) -> (int, int)"}
let result = cm_parser#python#parameters(completed_item)
AssertEqual ['(escape_character, input_filter, output_filter)'], result
"}}}
Execute (jedi):
let completed_item = {'word': 'test_func', 'menu': '[jedi] ', 'info': 'test_func(arg1, arg2)', 'kind': 'function', 'abbr': 'test_func(arg1, arg2)'}
let result = cm_parser#python#parameters(completed_item)
AssertEqual ['(arg1, arg2)'], result
Execute (coc.nvim + coc-pyhon[MPLS]):
let completed_item = {'word': 'fun', 'menu': '[LS]', 'user_data': '{"cid":1578967439,"source":"python","index":8}', 'info': '```\nfun(x, y)\n```', 'kind': 'v', 'abbr': 'fun'}
let result = cm_parser#python#parameters(completed_item)
AssertEqual ['(x, y)'], result
" echos
Execute (echos, foo):
let completed_item = {'menu': 'function:foo', 'info': "foo()\nfoo function"}
let result = cm_parser#python#echos(completed_item)
AssertEqual ['foo()'], result
Execute (echos, foo(a) -> int):
let completed_item = {'menu': 'function:foo', 'info': "foo(a) -> int \nfoo function"}
let result = cm_parser#python#echos(completed_item)
AssertEqual ['foo(a)'], result
Execute (echos, foo(a, b = []) -> int):
let completed_item = {'menu': 'function:foo', 'info': "foo(a, b = []) -> int \nfoo function"}
let result = cm_parser#python#echos(completed_item)
AssertEqual ['foo(a, b = [])'], result

View File

@ -0,0 +1,105 @@
" {{{ycm
Execute (error param):
let completed_item = {}
let result = cm_parser#rust#parameters(completed_item)
AssertEqual [], result
Execute (fn hello()):
let completed_item = {'word': 'hello', 'menu': 'fn hello()', 'kind': 'f'}
let result = cm_parser#rust#parameters(completed_item)
AssertEqual ['()'], result
Execute (fn hello() -> Self):
let completed_item = {'word': 'hello', 'menu': 'fn hello()', 'kind': 'f'}
let result = cm_parser#rust#parameters(completed_item)
AssertEqual ['()'], result
Execute (fn hello(capacity: usize) -> Vec<T>):
let completed_item = {'word': 'hello', 'menu': 'fn hello(capacity: usize) -> Vec<T>', 'kind': 'f'}
let result = cm_parser#rust#parameters(completed_item)
AssertEqual ['(capacity)'], result
Execute (fn hello(s: Cow<'a, [T]>) -> Vec<T>):
let completed_item = {'word': 'hello', 'menu': 'fn hello(s: Cow<''a, [T]>) -> Vec<T>', 'kind': 'f'}
let result = cm_parser#rust#parameters(completed_item)
AssertEqual ['(s)'], result
"}}}
" {{{ deoplete
Execute (error param):
let completed_item = {}
let result = cm_parser#rust#parameters(completed_item)
AssertEqual [], result
Execute (fn hello()):
let completed_item = {'word': 'hello', 'info': 'fn hello()', 'kind': 'Function'}
let result = cm_parser#rust#parameters(completed_item)
AssertEqual ['()'], result
Execute (fn hello() -> Self):
let completed_item = {'word': 'hello', 'info': 'fn hello()', 'kind': 'Function'}
let result = cm_parser#rust#parameters(completed_item)
AssertEqual ['()'], result
Execute (fn hello(capacity: usize) -> Vec<T>):
let completed_item = {'word': 'hello', 'info': 'fn hello(capacity: usize) -> Vec<T>', 'kind': 'Function'}
let result = cm_parser#rust#parameters(completed_item)
AssertEqual ['(capacity)'], result
Execute (fn hello(s: Cow<'a, [T]>) -> Vec<T>):
let completed_item = {'word': 'hello', 'info': 'fn hello(s: Cow<''a, [T]>) -> Vec<T>', 'kind': 'Function'}
let result = cm_parser#rust#parameters(completed_item)
AssertEqual ['(s)'], result
"}}}
" {{{ycm
Execute (error param):
let completed_item = {}
let result = cm_parser#rust#parameters(completed_item)
AssertEqual [], result
Execute (fn hello()):
let completed_item = {'word': 'hello(', 'info': 'fn hello()', 'kind': 'f', 'abbr': 'hello'}
let result = cm_parser#rust#parameters(completed_item)
AssertEqual ['()'], result
Execute (fn hello() -> Self):
let completed_item = {'word': 'hello(', 'info': 'fn hello()', 'kind': 'f', 'abbr': 'hello'}
let result = cm_parser#rust#parameters(completed_item)
AssertEqual ['()'], result
Execute (fn hello(capacity: usize) -> Vec<T>):
let completed_item = {'word': 'hello(', 'info': 'fn hello(capacity: usize) -> Vec<T>', 'kind': 'f', 'abbr': 'hello'}
let result = cm_parser#rust#parameters(completed_item)
AssertEqual ['(capacity)'], result
Execute (fn hello(s: Cow<'a, [T]>) -> Vec<T>):
let completed_item = {'word': 'hello(', 'info': 'fn hello(s: Cow<''a, [T]>) -> Vec<T>', 'kind': 'f', 'abbr': 'hello'}
let result = cm_parser#rust#parameters(completed_item)
AssertEqual ['(s)'], result
Execute (gen_range):
let completed_item = {'word': 'gen_range', 'menu': 'fn gen_range<T: PartialOrd + SampleRange>(&mut self, low: T, high: T) -> T where Self: Sized', 'info': '', 'kind': 'f', 'abbr': ''}
let result = cm_parser#rust#parameters(completed_item)
AssertEqual ['(low, high)'], result
Execute (has self):
let completed_item = {'word': 'gen_range', 'menu': 'fn gen_range(mut self, low: T, high: T) -> T where Self: Sized', 'info': '', 'kind': 'f', 'abbr': ''}
let result = cm_parser#rust#parameters(completed_item)
AssertEqual ['(low, high)'], result
Execute (trim):
let completed_item = {'word': 'trim', 'menu': 'pub fn trim(&self) -> &str', 'info': '', 'kind': 'f', 'abbr': ''}
let result = cm_parser#rust#parameters(completed_item)
AssertEqual ['()'], result
Execute (ends_with):
let completed_item = {'word': 'ends_with', 'menu': 'pub fn ends_with(&''a self, pat) -> &str', 'info': '', 'kind': 'f', 'abbr': ''}
let result = cm_parser#rust#parameters(completed_item)
AssertEqual ['(pat)'], result
Execute (mut ends_with):
let completed_item = {'word': 'ends_with', 'menu': 'pub fn ends_with(&''a mut self, pat) -> &str', 'info': '', 'kind': 'f', 'abbr': ''}
let result = cm_parser#rust#parameters(completed_item)
AssertEqual ['(pat)'], result
"}}}

View File

@ -0,0 +1,12 @@
#!/bin/bash -
set -e
vim -Nu <(cat << VIMRC
filetype off
set rtp+=~/.vim/bundle/vader.vim
set rtp+=~/.vim/bundle/CompleteParameter.vim
runtime! ~/.vim/bundle/CompleteParameter.vim/cm_parser/*.vim
filetype plugin indent on
syntax enable
VIMRC) -c 'Vader! ~/.vim/bundle/CompleteParameter.vim/vader/*' > /dev/null

View File

@ -0,0 +1,115 @@
" {{{ycm
Execute (error kind):
let completed_item = {}
let result = cm_parser#typescript#parameters(completed_item)
AssertEqual [], result
Execute (error abbr):
let completed_item = {'kind': 'm'}
let result = cm_parser#typescript#parameters(completed_item)
AssertEqual [], result
Execute (empty parameter):
let completed_item = {'kind': 'm', 'word': 'fun', 'abbr': 'fun (method) A.fun()'}
let result = cm_parser#typescript#parameters(completed_item)
AssertEqual ['()'], result
Execute (empty parameter 2):
let completed_item = {'kind': 'm', 'word': 'fun', 'abbr': 'fun (method) fun()'}
let result = cm_parser#typescript#parameters(completed_item)
AssertEqual ['()'], result
Execute (array.concat):
let completed_item = {'word': 'concat', 'menu': '', 'info': '', 'kind': 'm', 'abbr': 'concat (method) Array<number>.concat(...items: number[][]): number[] (+1 overload)'}
let result = cm_parser#typescript#parameters(completed_item)
AssertEqual ['(...items)'], result
Execute (array.every):
let completed_item = {'word': 'every', 'menu': '', 'info': '', 'kind': 'm', 'abbr': 'every (method) Array<number>.every(callbackfn: (this: void, value: number, index: number, array: number[]) => boolean): boolean (+2 overloads)'}
let result = cm_parser#typescript#parameters(completed_item)
AssertEqual ['(callbackfn)'], result
Execute (array.indexOf):
let completed_item = {'word': 'indexOf', 'menu': '', 'info': '', 'kind': 'm', 'abbr': 'indexOf (method) Array<number>.indexOf(searchElement: number, fromIndex?: number): number'}
let result = cm_parser#typescript#parameters(completed_item)
AssertEqual ['(searchElement, fromIndex)'], result
Execute (array.map):
let completed_item = {'word': 'map', 'menu': '', 'info': '', 'kind': 'm', 'abbr': 'map (method) Array<number>.map<U>(this: [number, number, number, number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U): [U, U, U, U, U] (+14 overloads)'}
let result = cm_parser#typescript#parameters(completed_item)
AssertEqual ['(this, callbackfn)'], result
"}}}
" {{{ deoplete
Execute (error kind):
let completed_item = {}
let result = cm_parser#typescript#parameters(completed_item)
AssertEqual [], result
Execute (error info):
let completed_item = {'kind': 'M'}
let result = cm_parser#typescript#parameters(completed_item)
AssertEqual [], result
Execute (empty parameter):
let completed_item = {'kind': 'M', 'word': 'fun', 'info': 'A.fun()'}
let result = cm_parser#typescript#parameters(completed_item)
AssertEqual ['()'], result
Execute (empty parameter 2):
let completed_item = {'kind': 'M', 'word': 'fun', 'info': 'fun()'}
let result = cm_parser#typescript#parameters(completed_item)
AssertEqual ['()'], result
Execute (array.concat):
let completed_item = {'word': 'concat', 'menu': 'TS Array<number>.concat(...i..(+1 overload)', 'info': 'Array<number>.concat(...items: number[][]): number[] (+1 overload)\nCombines two or more arrays.', 'kind': 'M', 'abbr': 'concat'}
let result = cm_parser#typescript#parameters(completed_item)
AssertEqual ['(...items)'], result
Execute (array.every):
let completed_item = {'word': 'every', 'menu': 'TS Array<number>.every(callb..+2 overloads)', 'info': 'Array<number>.every(callbackfn: (this: void , value: number, index: number, array: number[]) => boolean): boolean (+2 overloads)\nDetermines whether all the members of an array satisfy the specified test.', 'kind': 'M', 'abbr': 'every'}
let result = cm_parser#typescript#parameters(completed_item)
AssertEqual ['(callbackfn)'], result
Execute (array.indexOf):
let completed_item = {'word': 'indexOf', 'menu': 'TS Array<number>.indexOf(sea..mber): number', 'info': 'Array<number>.indexOf(searchElement: number, fromIndex?: number): number\nReturns the index of the first occurrence of a value in an array.', 'kind': 'M', 'abbr': 'indexOf'}
let result = cm_parser#typescript#parameters(completed_item)
AssertEqual ['(searchElement, fromIndex)'], result
Execute (array.map):
let completed_item = {'word': 'map', 'menu': 'TS Array<number>.map<U>(this..14 overloads)', 'info': 'Array<number>.map<U>(this: [number, number, number, number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U): [U, U, U, U, U] (+14 overloads) \nCalls a defined callback function on each element of an array, and returns an array that contains the results.', 'kind': 'M', 'abbr' : 'map'}
let result = cm_parser#typescript#parameters(completed_item)
AssertEqual ['(this, callbackfn)'], result
"}}}
" {{{ neocomplete
Execute (empty parameter):
let completed_item = {'kind': '', 'word': 'fun', 'menu': '(method) A.fun()'}
let result = cm_parser#typescript#parameters(completed_item)
AssertEqual ['()'], result
Execute (empty parameter 2):
let completed_item = {'kind': '', 'word': 'fun', 'menu': '(method) fun()'}
let result = cm_parser#typescript#parameters(completed_item)
AssertEqual ['()'], result
Execute (array.concat):
let completed_item = {'word': 'concat', 'menu': '(method) Array<number>.concat(...items: number[][]): number[] (+1 overload)\nCombines two or more arrays.', 'kind': '', 'abbr': 'concat'}
let result = cm_parser#typescript#parameters(completed_item)
AssertEqual ['(...items)'], result
Execute (array.every):
let completed_item = {'word': 'every', 'menu': '(method) Array<number>.every(callbackfn: (this: void , value: number, index: number, array: number[]) => boolean): boolean (+2 overloads)\nDetermines whether all the members of an array satisfy the specified test.', 'kind': '', 'abbr': 'every'}
let result = cm_parser#typescript#parameters(completed_item)
AssertEqual ['(callbackfn)'], result
Execute (array.indexOf):
let completed_item = {'word': 'indexOf', 'menu': '(method) Array<number>.indexOf(searchElement: number, fromIndex?: number): number\nReturns the index of the first occurrence of a value in an array.', 'kind': '', 'abbr': 'indexOf'}
let result = cm_parser#typescript#parameters(completed_item)
AssertEqual ['(searchElement, fromIndex)'], result
Execute (array.map):
let completed_item = {'word': 'map', 'menu': '(method) Array<number>.map<U>(this: [number, number, number, number, number], callbackfn: (this: void, value: number, index: number, array: number[]) => U): [U, U, U, U, U] (+14 overloads) \nCalls a defined callback function on each element of an array, and returns an array that contains the results.', 'kind': '', 'abbr' : 'map'}
let result = cm_parser#typescript#parameters(completed_item)
AssertEqual ['(this, callbackfn)'], result
"}}}