deoplete-clang2 icon indicating copy to clipboard operation
deoplete-clang2 copied to clipboard

specify compile_commands.json location?

Open directorscut82 opened this issue 8 years ago • 7 comments

Hello, Is there a setting to specify a directory (different than the root) that the plugin can use for the location of the compilation database??

directorscut82 avatar May 22 '17 16:05 directorscut82

No. I couldn't think of a reason why compile_commands.json would be outside of the project directory. What's your scenario?

tweekmonster avatar May 30 '17 00:05 tweekmonster

I have the same issue.. I am using meson>ninja project setup where the src and build directories are separeted

/.lvimrc
  build/compile_comands.json
  src/

I ususally start vim within the /src dir. deoplete-clang has

 let g:deoplete#sources#clang#clang_complete_database = g:localvimrc_script_dir.'/build'

stfl avatar Jun 12 '17 11:06 stfl

I'm not familiar with Meson, but I understand the problem now. I keep cwd as the project root so I don't have to screw around with paths in the compiler flags.

That variable is ignored in deoplete-clang2 (electric boogaloo). I consider compile_comands.json to be a project-specific thing, which makes having a fixed path using a global variable feel clumsy to me, even when using a local vim script. I prefer it to be automatic since it's all-or-nothing (there shouldn't be two compile_commands.json files per project).

This could search upward for a root repo directory then search for the compile_commands.json file from there. Could also have an option to specify a list of hints like let g:deoplete#sources#clang#compile_commands_search = ['../build'] (./ would always be the last resort). What do you think?

tweekmonster avatar Jun 18 '17 05:06 tweekmonster

yes. compile_commands.json is very project specific.. and for that I only set this in localvimrc anyway..

I think the search path should do the trick as well if you want to keep it more generic. It would still be very project specific but would make it work out of the box for the majority of meson.build and cmake projects, or am I mistaken?

stfl avatar Jun 19 '17 20:06 stfl

I just figured out that the let g:deoplete#sources#clang#clang_complete_database = g:localvimrc_script_dir.'/build' in deoplete-clang doesn't actually work properly.. struct members are not copleted f.e.

I am now using the .clang file that has an option like: compilation_database = "<path to compilation_database>"

would be an alternative solution.. ?

stfl avatar Jun 20 '17 13:06 stfl

I'd also like to note that the CMake build structure also uses a separate build directory than the source directory, so having some parameter somewhere would be useful.

As for now, a symlink does the job though.

JonBoyleCoding avatar Jul 19 '17 14:07 JonBoyleCoding

+1, a setting to specify a build directory containing the compilation database would be much appreciated.

przem8k avatar Jul 25 '17 11:07 przem8k