Add paren analysis to determine if need to add closing paren
See https://github.com/Hackerpilot/DCD/issues/75#issuecomment-28964235
This commit is contained in:
parent
129c746746
commit
fc82e5910a
|
@ -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
|
||||
```
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue