Skip to content

Instantly share code, notes, and snippets.

@xaizek
Created January 11, 2012 20:04
Show Gist options
  • Save xaizek/1596499 to your computer and use it in GitHub Desktop.
Save xaizek/1596499 to your computer and use it in GitHub Desktop.
function! ClangComplete(findstart, base)
if a:findstart
let l:line = getline('.')
let l:start = col('.') - 1
let b:clang_complete_type = 1
let l:wsstart = l:start
if l:line[l:wsstart - 1] =~ '\s'
while l:wsstart > 0 && l:line[l:wsstart - 1] =~ '\s'
let l:wsstart -= 1
endwhile
endif
if l:line[l:wsstart - 1] =~ '[(,]'
" modified here !!!|
let b:should_overload = 1
let l:start -= 1
endif
let b:should_overload = 0
while l:start > 0 && l:line[l:start - 1] =~ '\i'
let l:start -= 1
endwhile
if l:line[l:start - 2:] =~ '->' || l:line[l:start - 1] == '.'
let b:clang_complete_type = 0
endif
let b:col = l:start + 1
let g:aaa=l:start
return l:start
else
if g:clang_debug == 1
let l:time_start = reltime()
endif
if g:clang_snippets == 1
call b:ResetSnip()
endif
if g:clang_use_library == 1
" modified here !!!|
let l:base = a:base
if a:base[-1:-1] =~ '[(,]'
let l:base = a:base[:-2].'$'
endif
python vim.command('let l:res = ' + str(getCurrentCompletions(vim.eval('l:base'))))
else
let l:res = s:ClangCompleteBinary(a:base)
endif
for item in l:res
if g:clang_snippets == 1
let item['word'] = b:AddSnip(item['info'], item['args_pos'])
else
let item['word'] = item['abbr']
endif
endfor
if g:clang_snippets == 1
inoremap <expr> <buffer> <C-Y> <SID>HandlePossibleSelectionCtrlY()
augroup ClangComplete
au CursorMovedI <buffer> call <SID>TriggerSnippet()
augroup end
let b:snippet_chosen = 0
endif
if g:clang_debug == 1
echom 'clang_complete: completion time (' . (g:clang_use_library == 1 ? 'library' : 'binary') . ') '. split(reltimestr(reltime(l:time_start)))[0]
endif
return l:res
endif
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment