Mightyiam (talk | contribs)
Links to relevant Nixcademy blog posts
Skaphi (talk | contribs)
No edit summary
 
Line 272: Line 272:
to find C/C++ header files. Nixpkgs adds wrapper to all language server [https://clangd.llvm.org/ clangd] (recommend), [https://github.com/MaskRay/ccls ccls] and [https://github.com/cquery-project/cquery cquery] to extend the include path of these tools. [https://github.com/MaskRay/ccls/wiki CCLS] also provides extensive documentation on how to setup a project/editors to make use of it.
to find C/C++ header files. Nixpkgs adds wrapper to all language server [https://clangd.llvm.org/ clangd] (recommend), [https://github.com/MaskRay/ccls ccls] and [https://github.com/cquery-project/cquery cquery] to extend the include path of these tools. [https://github.com/MaskRay/ccls/wiki CCLS] also provides extensive documentation on how to setup a project/editors to make use of it.


But this is not enough for all projects. If you use clangd and your project generates a <code>compile_commands.json</code> which refers to a compiler which is in <code>/nix/store</code> you will need to set up your editor to start clangd with the following flags <code>clangd --query-driver=/nix/store/*/bin/g++ --query-driver=/nix/store/*/bin/gcc</code>. Clangd needs to query the compiler you are actually using to be able to find where the standard library headers are. This involves executing other binaries so clangd considers this unsecure for non-standard compiler paths. The flags whitelists all gcc and g++ compilers in the nix store.
== Use a different compiler version ==
== Use a different compiler version ==