0

How to make clang_complete to automaticaly complete not only after ., -> and ::, but after first three characters of the word for exampe?

shved
  • 386
  • 1
  • 12

1 Answers1

0

This isn't supported by clang_complete out of the box, but here is an example of how it could be implemented (this is rather a proof of concept rather than a working solution):

autocmd CursorMovedI *.h,*.c,*.hpp,*.cpp call FastInvoke()
function! FastInvoke()
    let l:col = col('.')
    if l:col == 1 || len(expand('<cword>')) != 0
        return
    endif

    let l:line = line('.')
    call cursor(l:line, l:col - 1)
    let l:wordlen = len(expand('<cword>'))
    call cursor(l:line, l:col)
    if l:wordlen == 3
        call feedkeys("\<c-x>\<c-u>")
    endif
endfunction

It measures length of a string returned by expand('<cword>'), which returns 0 at the end of a word. The bad thing about it is that it will try to complete everything, so you might get a lot of Failed to complete messages and low performance.

xaizek
  • 5,098
  • 1
  • 34
  • 60