jacobdufault / cquery

C/C++ language server supporting multi-million line code base, powered by libclang. Emacs, Vim, VSCode, and others with language server protocol support. Cross references, completion, diagnostics, semantic highlighting and more
MIT License
2.35k stars 162 forks source link

Completion Help for c++ on Ubuntu 16.04 #778

Open skopaas opened 6 years ago

skopaas commented 6 years ago

I made a script that gets all (????) the dependencies and files needed to make cquery work with LanguageClient-neovim on Ubuntu 16.04. Can anyone from the developers team test this script on a newly installed Ubuntu v > 16.04 OS? Can anyone check if there's anything missing to make cquery work for a sample c++ project like the one I create on the following shell script?

Here's the script that I made: https://github.com/ganimaedes/Client/blob/master/install_client_server.sh

The script uses a sample CMakeLists.txt , .vimrc/init.vim and settings.json files and tries to create a compile_commands.json and a .cquery files after having installed the LanguageClient-neovim in the appropriate directory if it wasn't already installed. It also modifies the install.sh file from LanguageClient-neovim to prevent any errors during installation.

Any help would be greatly appreciated since there seems to be a bug (?) on ubuntu 16.04 that blocks cquery from completing code as seen by these two posts: https://github.com/cquery-project/cquery/issues/762 & https://github.com/cquery-project/cquery/issues/763 (763 made by myself)

Thank you

innerout commented 6 years ago

Instead of building vim from source why dont you install it with apt-get?

skopaas commented 6 years ago

@innerout Indeed I've tried it out but installing with apt/apt-get doesn't change much. I was thinking maybe there was something missing/or something i wasn't doing right when i decided to install it manually to see if anyone would point to a wrong configuration. I still can't get any completion yet. Thanks for your help

innerout commented 6 years ago

For me this script is not even building cquery.

skopaas commented 6 years ago

@innerout I've changed it to what's proposed with the basic configurations ie :

git clone https://github.com/cquery-project/cquery.git --recursive
cd cquery
git submodule update --init
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=release -DCMAKE_EXPORT_COMPILE_COMMANDS=YES
cmake --build .
cmake --build . --target install

Are you able to build cquery using the commands above?

innerout commented 6 years ago

Now cquery builds but there is a problem in your vimrc for sure.

skopaas commented 6 years ago

@innerout yes there was a out of place pair of single quotes (' ') on line 15 of https://github.com/ganimaedes/dot_files/blob/master/.vimrc. Sorry for that, it is corrected now.

innerout commented 6 years ago

It works fine now.

skopaas commented 6 years ago

@innerout Do you mean you can get auto-completion when writing on the sample.cpp ?

innerout commented 6 years ago

Auto completion didn't popup but language server seemed to fire up and work. I think you need an autocomplete plugin that supports lsp in vim (deoplete) in your vimrc but i am not sure as i am not a vim user.

smhc commented 6 years ago

LanguageClient-neovim will start cquery for you. It doesn't need to be started manually. Does cquery exist at '~/cquery/build/cquery' for the current user? It could be an issue with the ~ being mapped to the home dir for root during install, vs home dir for the current user. You may want to change the .vimrc to use /usr/local/bin/cquery instead.

You should be able to complete with ctrl-x ctrl-o. If that works but you aren't getting an 'as you type popup', the problem is just a missing autocomplete plugin. You'd need an additional plugin such as vim-mucomplete, see https://github.com/lifepillar/vim-mucomplete/wiki/Cpp--member-auto-completion