<div dir="ltr"><div>Yep, unfortunately clangd doesn't manage any of this for you now. </div><div><br></div>A fully-fledged version of this feature would be: if the compile command for a file compiles a different file, then we should complete as if we were compiling the outer file. This is hard due to our use of the preamble optimization and our assumptions the file is self contained. <a href="https://github.com/clangd/clangd/issues/45">https://github.com/clangd/clangd/issues/45</a> - YCM folks have also requested this, it's hard to fix.<div><br></div><div>On the other hand it should be easy to simply adjust the compile command to point to the right file. You won't see e.g. #includes or #defines from the *_package.cpp wrapper, but this would still work in many cases. We should probably do that for now.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, May 28, 2019 at 10:20 AM Dovod Dovodov via clangd-dev <<a href="mailto:clangd-dev@lists.llvm.org">clangd-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi Mikael,<div><br></div><div>I guess you should also fix "command" part in order to make clangd work with fine. So apart from fixing "file" you should replace *_package.cpp and *package.cpp.o entries in the "command" arguments with needed .cpp file paths. Just checked it, with improper "command" with clangd + emacs + lsp on macos I have no code completion.</div></div><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, 28 May 2019 at 11:00, Mikael Springer via clangd-dev <<a href="mailto:clangd-dev@lists.llvm.org" target="_blank">clangd-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi.<br>
<br>
We have our code structured in a somewhat unusual way. All *.cpp source files are included (#include …) in a number of *_package.cpp files. These *_package.cpp files are the ones configured in a Xcode project and in a Visual Studio project. The primary reason for this organization is to minimise the need to update Xcode and Visual Studio projects when adding new source files to the project (one just includes the new file in a suitable *_package.cpp file which is already a part of the project).<br>
<br>
A consequence of this is that only the *_package.cpp files are visible in the compilation output. When we generate a compile_commands.json (using xcpretty since I’m on MacOS and using Xcode) this compilation database only contains entries for the *_package.cpp files. If I want to use for example Emacs and LSP this doesn’t work since a large part of the code base is not in the compilation database.<br>
<br>
Would it be possible to add entries for each cpp source file that is included in the *_package.cpp files to the compile_commands.json (using a script). Would Clangd be able to parse this correctly? The idea is to copy the corresponding *_package.cpp entry in which the source file is included and alter the “file” part of the entry to refer to the source file instead, but leave the “command” part intact. This makes sense in a way since this is the way the source file is compiled even if it doesn’t show. Can Clangd work with this input?<br>
<br>
Regards, Micke.<br>
<br>
_______________________________________________<br>
clangd-dev mailing list<br>
<a href="mailto:clangd-dev@lists.llvm.org" target="_blank">clangd-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/clangd-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/clangd-dev</a><br>
</blockquote></div>
_______________________________________________<br>
clangd-dev mailing list<br>
<a href="mailto:clangd-dev@lists.llvm.org" target="_blank">clangd-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/clangd-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/clangd-dev</a><br>
</blockquote></div>