xavierd / clang_complete

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

clang_complete "working " but User defined completion (^U^N^P) Pattern not found #452

Open floringogianu opened 9 years ago

floringogianu commented 9 years ago

Clang_complete seems to be working because if I type std:: I do get a list of methods and types. However on a simple test case I get the error in the title:

#include <vector>
#include <iostream>

int main()
{
    std::vector<int> v;
    v.
    return 0;
}

Environment

Apple LLVM version 7.0.0 (clang-700.0.65)
Target: x86_64-apple-darwin15.0.
let g:clang_library_path = "/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/"
let g:clang_user_options='|| exit 0'
let g:clang_complete_auto = 1
let g:clang_complete_copen = 1
let g:clang_debug = 1

I also tried without the clang library path, but the clang_complete plugin would ask for the path.

xaizek commented 9 years ago

Are you sure that clang_complete is responsible for user-defined completion, i.e. what's the output of set completefunc??

floringogianu commented 9 years ago

Output is completefunc=ClangComplete

floringogianu commented 8 years ago

@xaizek I am not experiencing this behaviour with the release (non-beta) versions of Xcode 7 and El Capitan. Everything is working fine with the same clang_complete settings as above.

xaizek commented 8 years ago

It might be related to version of libclang provided with release/beta versions, maybe something is wrong with python bindings.

jlstr commented 8 years ago

@floringogianu Hi! I'm experiencing the exact same problem of this thread. Did you do something additional in order to make it work? I don't know how to configure the famous .clang_complete file (nor do I know where to locate it). Did you change it somehow? -Thanks

floringogianu commented 8 years ago

@jlstr I didn't configure the .clang_complete file, the lines you see above are in the .vimrc. For me this got away when I moved out of El Capitan beta to the final release. The clang version shipping with xcode changed also, so maybe that has something to do with it, as @xaizek mentioned. I'll be soon testing this on linux also and report back.

jlstr commented 8 years ago

Interesting. You're using MacVim I assume. Could you please tell me which version of MacVim do you currently use, also which version of system vim do you have which vim (in terminal).

It's been a really weird experience for me, because 2 days ago when I installed it, it occasionally worked. But recently, only completions of the kind std:: work, and completions of the kind variable. don't (throw User defined completion (^U^N^P) Pattern not found). I have the latest of the latest (both XCode & El Capitan)

Thank you for your kind reply!

floringogianu commented 8 years ago

@jlstr I am using MacVim 7.4.903, installed with homebrew. System vim is 7.3 but I am not using that one. I can't figure out why is this happening either.. I'm now using python 2.7.10 also with brew. I can't recall what python I was using back when it was not working..

jlstr commented 8 years ago

Hey! thank you for the reply, It's good that you have answered because I need to report that everything's working well for me now, mainly for two reasons: 1) I learned how to install MacVim in Mac OSX properly (using brew and with the --with-override-system-vim option), and 2nd) I turned off the YouCompleteMe plugin, as turns out that plugin is non-compatible with clang_autocomplete. (Kind of obvious, no?) as they both perform completions of the nature variable. Thank you once again for your kind reply!

tibco-ranjan commented 5 years ago

I resolved this problem by putting .clang_complete file in the root of my source project as stated in the https://github.com/Rip-Rip/clang_complete link.


solution exmaple [centOS 7]

  1. my project dir root@localhost:~/LapiMyProg/CPP/DesingPatterns/CompoAggregAsscoc_bkp# ls -lart total 12 -rw-r--r--. 1 root root 1639 Nov 17 16:33 main.cpp drwxr-xr-x. 6 root root 125 Nov 17 16:39 .. -rw-r--r--. 1 root root 2693 Nov 17 18:54 Makefile drwxr-xr-x. 2 root root 18 Nov 17 18:57 Linux -rw-r--r--. 1 root root 13 Nov 17 19:07 .clang_complete drwxr-xr-x. 5 root root 103 Nov 17 19:07 . drwxr-xr-x. 2 root root 156 Nov 17 19:09 include drwxr-xr-x. 2 root root 164 Nov 17 19:12 source

  2. Made an entry of my include folder in the .clang_complete file. root@localhost:~/LapiMyProg/CPP/DesingPatterns/CompoAggregAsscoc_bkp# cat .clang_complete -I./include/

In my include folder, I have put all my headers files as shown below. In my source folder, I have put all my cpp files. root@localhost:~/LapiMyProg/CPP/DesingPatterns/CompoAggregAsscoc_bkp# cd include/ root@localhost:~/LapiMyProg/CPP/DesingPatterns/CompoAggregAsscoc_bkp/include# ls aggre_department.h aggreg_teacher.h assoc_doctor.h assoc_paitent.h common.h comp_house.h comp_room.h


Check if user-defined data types worked or not.

root@localhost:~/LapiMyProg/CPP/DesingPatterns/CompoAggregAsscoc_bkp# vim source/comp_house.cpp

std::ostream& operator<<(std::ostream& out, const House &house) { std::vector roomList = house.getRoomList(); roomList.pu out<<"To push_back f void push_back(const std::vector<Room, std::allocator >::value_type &__x) out<<"Name of the Rooms are" <<endl; out<<"========================"<<endl;

    for(unsigned i=0; i< roomList.size(); i++)
    {
            roomList[i].DisplayRoom();
    };
    out<<"========================"<<endl;
    return out;

}


Result

As shown above

std::vector roomList = house.getRoomList(); roomList.

successfuly provides all the vector method (push_back)


Hope this will Help

ianbrault commented 5 years ago

I have the same setup as @tibco-ranjan but still get the same error as the original issue poster.