-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
compile commands is not working in lsp-mode(ccls) #50
Comments
Please paste text, not images.
Tip: cmake -H. -Bbuild -DCMAKE_EXPORT_COMPILE_COMMANDS=ON to avoid Here are some things you should try before filing a bug report:
If none of those help, remove this section and fill out the four sections in the template below. Observed behaviorDescribe what happened. Any aids you can include (that you think could be relevant) are a tremendous help.
Expected behaviorDescribe what you expected to happen. Steps to reproduce
System information
|
I've met the exact same phenomenon, and I solved it by adjusting the compiler flags. TL;DR, I find the lsp server will work as long as the project can be built with clang(note: working with gcc does not state that the project will work with clang). long long story below I record my experience here in case people may meet the same problem. Note, I'm new to c++ and c++ build system. My System EnvironmentI have a system(centos 7.6), which installed devtoolset-7(gcc 7). My Project InfoI try to use ccls on https://github.com/tikv/titan project. After I run
I can see the compiler_commands.json, and the first several lines looks like this ☁ ~/p/titan master* > head -6 compile_commands.json
[
{
"directory": "/root/xxx/titan/build",
"command": "/opt/rh/devtoolset-7/root/usr/bin/c++ .............. -W -Wextra -Wall -Wsign-compare -Wshadow -Wno-unused-parameter -Wno-unused-variable -Woverloaded-virtual -Wnon-virtual-dtor -Wno-missing-field-initializers -Wno-strict-aliasing -std=c++11 -fno-omit-frame-pointer -momit-leaf-frame-pointer -march=native -Werror -fno-builtin-memcmp -o CMakeFiles/titan_blob_file_iterator_test.dir/src/blob_file_iterator_test.cc.o -c /root/xxx/titan/src/blob_file_iterator_test.cc",
"file": "/root/xxx/titan/src/blob_file_iterator_test.cc"
}, And I try to start my Emacs and open the project, but it does not work, and the lsp server(ccls) always responds with I'm pretty sure that there are some problems in my json file, however, I do not know where the problem is (I think the root cause is that I do not know the working mechanism of ccls and I have little knowledge about c++). After long time searching, I decide to try I search the error message in clangd source code and I found the reason this happens is that the compiler should be clang instead of gcc. So I disable my gcc and try to re-build my project with clang, to my surprise, the build-process failed. After some investigation, I adjust some compile flags and the project can be built with clang.
After that, the lsp server also works 🙈. I change the lsp server from clangd to ccls, and it also works well. |
Hello, I'm trying to use for the first time lsp-mode for my C/C++ projects. This is my minimal(I think) configuration for this.
When I did open the first project some functions definitions were being recognized and etc, but I was with a problem related to some libraries that were not being found. In order to solve this I read this link https://github.com/MaskRay/ccls/wiki/lsp-mode and compiled my project to generate the compile_commands.json. After that, everything seems don't work, flycheck, autocomplete and etc, and this msg(LSP :: not indexed) is being shown in every line.
How can I solve this and make lsp-mode work for me? Do I need to write something else in my config file? Just to be clear, I generated compile_commands.json with
mkdir build && cd build && cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=YES .. && ln -s compile_commands.json
.I posted this in reddit and the people tell me that the problem was with ccls and I should ask here what can be happening.
The text was updated successfully, but these errors were encountered: