Give the path for compile_commands.json file to coc-clangd

Viewed 1600

so I'm a developer working mostly with c using yocto/openembedded for developing our products. I'm trying to set up my nvim with coc-cland as an IDE, but having some problems.

So what I want is to give languageserver the compile_commands.json file. I have the setup working when the compile_commands.json is in the "root of the src dir" but the compile_commands.json is normally not generated in the source folder instead it is generated to <root of src dir>/oe-workdir/<project name>/compile_commands.json. How do I tell coc to use that file if it exists? Finding the file is easy using shell script, but what variable shall I set and where?

My :CocConfig looks like:

{ 
  "languageserver": {
    "coc-clangd": {
      "command": "clangd",
      "rootPatterns": [ ".git/", "compile_flags.txt", "compile_commands.json"],
      "filetypes": ["c", "cc", "cpp", "c++", "objc", "objcpp"]
    }                                     
  }                                       
}                                       

I have found some relevant git for coc-clangd (https://github.com/clangd/coc-clangd) where it states that I can set the clangd.arguments but I need to do it dynamically as the <project name> folder changes name from project to project, can I do it in the :CocConfig or can I do it in my vimrc/init.vim?

0 Answers
Related