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`
|
This plugin conflicts with the DScanner plugin, as both use the `dcomplete`
|
||||||
autoload namespace and the `dcomplete#Complete` function - as per Vim's
|
autoload namespace and the `dcomplete#Complete` function - as per Vim's
|
||||||
conventions.
|
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
|
"The completion function
|
||||||
function! dcomplete#Complete(findstart,base)
|
function! dcomplete#Complete(findstart,base)
|
||||||
if a:findstart
|
if a:findstart
|
||||||
|
|
||||||
|
"We might need it for paren completion:
|
||||||
|
let b:closingParenExists=getline('.')[col('.')-1:-1]=~'^\s*)'
|
||||||
|
|
||||||
let prePos=searchpos('\W',"bn")
|
let prePos=searchpos('\W',"bn")
|
||||||
let preChar=getline(prePos[0])[prePos[1]-1]
|
let preChar=getline(prePos[0])[prePos[1]-1]
|
||||||
if '.'==preChar
|
if '.'==preChar
|
||||||
|
@ -131,7 +135,10 @@ function! s:parseCalltips(base,resultLines)
|
||||||
call add(funcArgs,'')
|
call add(funcArgs,'')
|
||||||
endif
|
endif
|
||||||
endfor
|
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})
|
call add(result,{'word':funcArgsString,'abbr':substitute(resultLine,'\\n\\t','','g'),'dup':1})
|
||||||
end
|
end
|
||||||
endfor
|
endfor
|
||||||
|
|
Loading…
Reference in New Issue