I have tried using CMake to build ccls many times and I have just about given so if anyone has a way to do it that would be mega helpful.
I am on Fedora Linux and I am using the repo to get ccls as the prebuilt binaries don't work.
Any help would be appreciated. Thanks.
CodePudding user response:
To get it to work on Fedora (I don't see any reason why it shouldn't work on other Linux distros) this is how I did it step by step:
Quick note: You may want to use sudo yum install clang-devel
and sudo yum install llvm-devel
since they potentially hold needed dependencies. Also make sure you have downloaded the other things you will need as instructed on the ccls wiki.
Firstly I used
git clone --depth=1 --recursive https://github.com/MaskRay/ccls
to clone the repo into a folder.Secondly I went into the ccls folder and used
cmake .
. Which built the required things.Thirdly I the used the
make
command to fully build the repo and generate the ccls executable.Then I created a bin directory in the home directory and moved the ccls executable into it.
Then I went into the .bashrc to add ccls to the system path and added the line
export PATH="/home/$USER/bin:$PATH"
to the final line of the bashrc. Then exited the file and usedsource ~/.bashrc
to force a resetFinally I added the ccls language server settings to the coc config:
{
"languageserver": {
"ccls": {
"command": "ccls",
"filetypes": ["c", "cpp", "cuda", "objc", "objcpp"],
"rootPatterns": [".ccls-root", "compile_commands.json"],
"initializationOptions": {
"cache": {
"directory": ".ccls-cache"
},
"client": {
"snippetSupport": true
}
}
}
}
}
Alternatively you can (if you are using coc) use CocInstall coc-clangd
in vim or nvim, which is a way you can get something similar to ccls for programming.