deoplete-plugins / deoplete-clang

deoplete.nvim source for C/C++/Obj-C/Obj-C++ with clang-python3
MIT License
189 stars 73 forks source link

How to enable completion for external libraries? #34

Closed ambasta closed 8 years ago

ambasta commented 8 years ago

Hi,

While deoplete-clang works wonders for stdlib, libraries such as boost/asio etc do not lead to code completion. How do I enable support for external libraries?

Environment Information

let g:deoplete#enable_at_startup = 1
let g:deoplete#auto_complete_start_length = 1
let g:deoplete#sources#clang#libclang_path = "/usr/lib64/libclang.so"
let g:deoplete#sources#clang#clang_header = "/usr/lib64/clang/3.8.0/include/"
let g:deoplete#sources#clang#std#cpp = 'c++1z'
let g:deoplete#sources#clang#sort_algo = 'priority'
let g:deoplete#sources#clang#flags = [
    \ "-stdlib=libc++",
    \ ]
zchee commented 8 years ago

@ambasta Hi,

At first, I'm nerver written C and C++ \o/ So, I do not write even sample code.

next, you want to complete boost/asio library? It should be complemented if it's include in the code that is written by you. I want an operation test. Could you post a sample code?


Sorry, close of issue is mistake.

ambasta commented 8 years ago
// Header names do not autocomplete //
#include <boost/graph/use_mpi.hpp>
#include <boost/graph/distributed/mpi_process_group.hpp>
#include <boost/graph/distributed/dijkstra_shortest_paths.hpp>
#include <boost/graph/distributed/adjacency_list.hpp>

#include <fstream>
#include <string>

#ifdef BOOST_NO_EXCEPTIONS
    void boost::throw_exception(std::exception const& exc) {
        std::cout << exc.what() << std::endl;
    }
#endif

using namespace boost;
using boost::graph::distributed::mpi_process_group;

// definitions such as adjacency_list etc don't always autocomplete
typedef adjacency_list<vecS, distributedS<mpi_process_group, vecS>, undirectedS, property<vertex_distance_t, float>, property<edge_weight_t, float> > Graph;

int main(int argc, char* argv[]) {
    return 0;
}
Shougo commented 8 years ago

I will test it later.

Shougo commented 8 years ago

I have tested this feature in your minimal init.vim.

https://github.com/Shougo/neoinclude.vim

ambasta commented 8 years ago

@Shougo Any ideas on how I can speed this up?

haifengkao commented 8 years ago

YCM is very fast for external libraries as well

zchee commented 8 years ago

@haifengkao We know lol We will do our best so that the equal speed.

haifengkao commented 8 years ago

@zchee I don't really understand why deoplete is slow for external libraries. libclang should work for external libraries (and fast). The only thing you need is to specify the header locations.

zchee commented 8 years ago

@haifengkao

I don't really understand why deoplete is slow for external libraries. libclang should work for external libraries (and fast). The only thing you need is to specify the header locations.

Yes, libclang is faster and de-facto library for parse C language. (and fast) meaning of on YCM? If so, Yes. YCM also uses libclang. But it's real libclang shared library.

Maybe(I do not much look at the YCM code) parse buffer, conversion AST to complete word or whatever, were executed C++ side. Not through a Python. We use libclang-python3. It's libclang binding for Python3, and performance will degraded because bypass a Python. (If you have experience with the libclang-python and was not slow, please let me know)

I think If included small external library such as dispatch.h, it will fast(tested). But boost library seems large(I never used boost), very slow. However, the slow cause might be a problem with the current deoplete-clang code, so we are during the validation now.

zchee commented 8 years ago

@haifengkao Ah, I'm overlooked.

The only thing you need is to specify the header locations.

In other word? like -I/usr/local/include/foo?

haifengkao commented 8 years ago

@zchee YES.