From fc82e5910aba1b8fc80956838586bf1d8239aae8 Mon Sep 17 00:00:00 2001 From: IdanArye Date: Wed, 27 Nov 2013 21:45:55 +0200 Subject: [PATCH] Add paren analysis to determine if need to add closing paren See https://github.com/Hackerpilot/DCD/issues/75#issuecomment-28964235 --- editors/vim/README.md | 8 ++++++++ editors/vim/autoload/dcomplete.vim | 9 ++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/editors/vim/README.md b/editors/vim/README.md index de5448b..712ad69 100644 --- a/editors/vim/README.md +++ b/editors/vim/README.md @@ -44,3 +44,11 @@ Conflicts This plugin conflicts with the DScanner plugin, as both use the `dcomplete` autoload namespace and the `dcomplete#Complete` function - as per Vim's conventions. + +Configuration +============= + +If you want to never add the closing paren in calltips completions, add this to you vimrc: +```vim +let g:dcd_neverAddClosingParen=1 +``` diff --git a/editors/vim/autoload/dcomplete.vim b/editors/vim/autoload/dcomplete.vim index 608f799..0d337e7 100644 --- a/editors/vim/autoload/dcomplete.vim +++ b/editors/vim/autoload/dcomplete.vim @@ -1,6 +1,10 @@ "The completion function function! dcomplete#Complete(findstart,base) if a:findstart + + "We might need it for paren completion: + let b:closingParenExists=getline('.')[col('.')-1:-1]=~'^\s*)' + let prePos=searchpos('\W',"bn") let preChar=getline(prePos[0])[prePos[1]-1] if '.'==preChar @@ -131,7 +135,10 @@ function! s:parseCalltips(base,resultLines) call add(funcArgs,'') endif endfor - let funcArgsString=join(funcArgs,', ').')' + let funcArgsString=join(funcArgs,', ') + if !b:closingParenExists && !(exists('g:dcd_neverAddClosingParen') && g:dcd_neverAddClosingParen) + let funcArgsString=funcArgsString.')' + endif call add(result,{'word':funcArgsString,'abbr':substitute(resultLine,'\\n\\t','','g'),'dup':1}) end endfor