how to add include path for language servers in coc-settings.json file?
See original GitHub issueHi there.
since I work in ros platform I want to add the headers of the ros(/opt/ros/kinetic/include/**) to my default include path of language servers for ros projects. with out this option, at the beginning of each project I must add a dummy ros node(is ros node means a cpp file), and compile with catkin_make -DCMAKE_EXPORT_COMPILE_COMMANDS=YES
to generate the compile_commands.json file to get access to ros headers in the completion list.
the contents of my coc-setting file, is as below:
{
"languageserver": {
"clangd": {
"command": "clangd",
"rootPatterns": ["compile_flags.txt", "compile_commands.json"],
"filetypes": ["c", "cpp", "objc", "objcpp"]
},
"cquery": {
"command": "/home/amirrezasadeghi/ManBuildLibs/cquery/build/cquery",
"args": ["--log-file=/tmp/cq.log"],
"filetypes": ["c", "cpp"],
"rootPatterns": ["compile_flags.txt", "compile_commands.json", ".git/", ".hg/"],
"initializationOptions": {
"cacheDirectory": "/tmp/cquery"
}
},
"ccls": {
"command": "ccls",
"filetypes": ["c", "cpp", "objc", "objcpp"],
"rootPatterns": [".ccls", "compile_commands.json", ".git/", ".hg/"],
"initializationOptions": {
"cache": {
"directory": "/tmp/ccls"
}
}
}
},
"clangd.semanticHighlighting": true
}
So my major question is how to add ros include path to these settings. I checked the wiki page of coc.nvim but can’t find any option for user include path. also, I checked the option of clangd and tried to add,
"args":["-I/opt/ros/kinetic/include/"]
,
to the corresponding block but it did not work. also, I added .cquery file, but still no effect on the list of the proposed headers.
sorry for long story, and thanks for your time.
Edit: it would be better to use the clangd LSP rather than ccls. because it is faster and has better documentation. thanks!
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:10 (5 by maintainers)
Top GitHub Comments
Hi there. thank you guys for your help and descriptions. finally, I found a way to make the procedure of adding include path like the procedure of VSCode. so I wrote a remote plugin in python(neovim_includePlug_draft.py.zip) which exports a Command(
:IncludePath
). by running this command, it prompts you to enter the include path then it automatically adds this path to compile options of the corresponding file in thecompile_commands.json
file. so without regeneration of the JSON file, you will have headers of the included path in your autocompletion. thank you all …Generally speaking clangd treats include paths as a per-project setting, and you should have a compile_commands.json file generated by your build system, or the simpler compile_flags.txt which could contain just
-I/opt/ros/kinetic/include
. http://clangd.llvm.org/installation.html#project-setupIf you don’t want to add this to every project directory, you can place the compile_flags.txt somewhere (
/some/for/compile_flags.txt
) and use the clangd flag-compile-commands-dir=/some/dir
.Be aware that using compile_flags.txt means background indexing won’t work, as it doesn’t provide the list of files to consider part of the project.