Clang Complete for Vim

后端 未结 5 923
盖世英雄少女心
盖世英雄少女心 2021-01-30 14:53

I copied clang_complete.vim to plugin, but when I typed . after some variable, it says:

pattern not found

相关标签:
5条回答
  • 2021-01-30 15:21

    I had the same problem and resolved it by adding the following to my .vimrc

    let g:clang_user_options='|| exit 0'
    
    0 讨论(0)
  • 2021-01-30 15:25

    To configure Vim, you must find or create your .vimrc file:

    $ vim ~/.vimrc

    Then enter:

    let g:clang_complete_copen = 1
    
    0 讨论(0)
  • 2021-01-30 15:28

    Did you try to compile the code outside Vim, by explicitly invoking Clang on the command-line?

    I had the same problem with my code, but it turns out Clang was not able to compile my code due to usage of the MPI libraries (mpich2). Maybe a similar problem is causing Clang to fail in your case? In my case, if I remove the MPI-dependencies, everything works fine, for example in something like:

    #include <iostream>
    #include <string>
    
    int main() {
        std::string myString("test string");
        std::cout << myString.size() << std::endl; // After typing the dot, I get a list of std::string methods
    }
    

    By-the-way, I still miss clang_complete in my MPI code. Did anyone find a solution for this?

    0 讨论(0)
  • 2021-01-30 15:30

    The following got things working for me on Cygwin using clang version 3.0 (tags/RELEASE_30/final), as well as on Windows using the Clang build instructions and a version checked out from trunk (usually stable, as I've read) yesterday (clang version 3.1 (trunk 154056)) and built with Visual Studio 2010:

    " clang_complete
    let g:clang_complete_auto = 0
    let g:clang_complete_copen = 1
    " :h clang_complete-auto_user_options
    if has('win32unix') " Cygwin
           " Using libclang requires a Vim built with +python
           let g:clang_use_library = 1
           " Mit der Option "gcc" kriege ich Fehler.
           " Remove "gcc" option as it causes errors.
           let g:clang_auto_user_options='path, .clang_complete'
    elseif has('win32') " Windows
           let g:clang_auto_user_options='path, .clang_complete'
           let g:clang_use_library = 1
           let g:clang_library_path='D:\Sourcen\LLVM\build\bin\Debug'
    endif
    

    Note that the Windows version may have sporadic assertion failures but works fine, although not exactly like the Cygwin version. Guess it's to do with using MSVC versus GCC header files.

    The Cygwin version has an initial error: release unlocked lock, but it works regardless.

    0 讨论(0)
  • 2021-01-30 15:31

    Try opening a sample file

    vim /tmp/sample.cpp
    

    and enter some cpp code

    #include <iostream>
    
    int main() {
      std:: // <-- this should complete
    }
    

    Note that you actually need to include the headers, since completion is done with the compiler. If this works, but your project still keeps saying "Pattern not found" then clang++ is probably not able to compile your project. Do you use any -I switches when you compile your code? Add them to a file named .clang_complete in your project directory.

    For me this works fine with my .vim/plugin folder containing only the clang_complete.vim file that is available for download:

    $ find .vim
    .vim
    .vim/plugin
    .vim/plugin/clang_complete.vim
    

    ... but in this issue report https://github.com/Rip-Rip/clang_complete/issues/39 it is suggested that you might need more than that file (additional files are in the git repo).

    0 讨论(0)
提交回复
热议问题