Rip-Rip/clang_complete — pull request #148 by dave-h (2012-05-09 20:17:57+00:00)
Title: Load per-file compile flags from compile_commands.json

This adds the custom option source `compile_commands` which loads a `compile_commands.json` file containing the full command line to compile individual source files. This allows it to set `b:clang_user_options` appropriately for each file.

For CMake based projects, this file can be auto-generated in the build tree by setting CMAKE_EXPORT_COMPILE_COMMANDS, e.g.

# cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON .

Note, I got the idea for this from looking at the new LibTooling in Clang which it appears will have built in support for reading compile_commands.json. So it might one day make more sense to use LibTooling itself for loading this file instead, but for now this seems to work fine for an initial version.

The actual format of the file looks like:

```
[
{
"directory": "",
"command": "",
"file": ""
},
...
]
```