tweekmonster / deoplete-clang2

MIT License
90 stars 17 forks source link

specify compile_commands.json location? #14

Open directorscut82 opened 7 years ago

directorscut82 commented 7 years ago

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??

tweekmonster commented 7 years ago

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

stfl commented 7 years ago

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'
tweekmonster commented 7 years ago

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?

stfl commented 7 years ago

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 commented 7 years ago

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.. ?

JonBoyleCoding commented 7 years ago

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.

przem8k commented 7 years ago

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