xavierd / clang_complete

Vim plugin that use clang for completing C/C++ code.
http://www.vim.org/scripts/script.php?script_id=3302
1.96k stars 308 forks source link

Unable to complete loop constructs #553

Open fandahao17 opened 6 years ago

fandahao17 commented 6 years ago

Thank you for your excellent plugin! I'm using Ubuntu17.10 with VIM 8 ,Clang 4.0.1 .After testing out all the features I found it unable to complete loop constructs. This is my configurations in ~/.vimrc :

let g:clang_library_path='/usr/lib/llvm-4.0/lib/libclang-4.0.so.1'
let g:clang_snippets = 1 
let g:clang_use_library = 1 
let g:clang_auto_select = 2 
let g:clang_complete_macros = 1 
let g:clang_complete_patterns = 1 
let g:clang_trailing_placeholder = 1 

When I open a C source file and check let g:clang_complete_patterns It turns out : g:clang_complete_patterns #1 I also checked let g:clang_complete_lib_flags and it seemed no problem as well g:clang_complete_lib_flags #3

But when I type for<C-X><C-U> ,expecting clang_complete to complete the whole loop construct, it reports "Pattern not found" and my quickfix list shows nothing wrong.The same problem occurs when I tries the while loop and the do-while loop. This has been confusing me for a few days, but I haven't got any idea of what's going wrong. So what possibly caused the failure of the completion of code patterns? Are there any prerequisites to completing a loop construct? BTW,the g:clang_trailing_placeholder option doesn't seem to work as well, but it can complete snippets like function parameters.So I don't know whether my problem is related to the snippet engine(I'm using 'clang_complete' as my snippet engine as default).

xaizek commented 6 years ago

clang_complete has never completed any loops, it completes identifiers like names of variables, types, macros and functions.

fandahao17 commented 6 years ago

Thanks.....But what does the "loop constructs" here refer to?

                                        clang_complete-complete_patterns
                                        g:clang_complete_patterns
If clang should complete code patterns, i.e loop constructs etc.
Default: 0
xaizek commented 6 years ago

I must be wrong then, haven't used the plugin for a long time. It seems to match doxygen, but I don't remember how to trigger it (maybe there shouldn't be any prefix at all?).

fandahao17 commented 6 years ago

Triggering code completion without any prefix doesn't work either.It just lists out a long list of all the possible selections. The option clang_complete_patterns doesn't change the completion result at all. I tried to trigger Clang code completion manually in the command line: $ clang -fsyntax-only -fno-caret-diagnostics -fdiagnostics-print-source-range-info -Xclang -code-completion-at='MyFile.c':6:3 'MyFile.c' -Xclang -x -Xclang c -Xclang -code-completion-patterns -Wall The output contains loop constructs like:

COMPLETION: Pattern : for(<#init-statement#>;<#condition#>;<#inc-expression#>){
<#statements#>
}

It seems my Clang is able to complete code patterns, I doubt if clang_complete still provides code pattern completion now.