Re: Some questions regarding LSP integration
Waqar Ahmed <[email protected]>
| Newsgroups | gmane.comp.kde.devel.kwrite |
|---|---|
| Message-ID | <CAPesRH7+qv1SgsaTZmv0mRQ=NBQDCgQu9c2=xvNTyndD_DCFdQ@mail.gmail.com> |
Hi, Yes, that is more or less what clangd does. > (so this will often fail) Yes, if there is no compile_commands.json found. And there can be multiple build dirs with multiple different compile_commands.json lying around (Think about people working on porting kde software to Qt6, they may have 2 build dirs one for Qt5 and one for Qt6, both having different compile_commands). So, automating this will not work for all scenarios. We currently have a solution in works which is: Implementing basic CMake support. One of the features is to automatically copy the compile_commands.json file to the root dir of the project from the "active" build directory / cmake preset. This will solve the problem for all cmake based projects. > According to the clangd documentation it's currently not possible to tell clangd where the compile_commands.json file is. Correct ? It is, but you don't want to do that usually, its very cumbersome as you need to specify it as a command line arg. On Thu, Feb 10, 2022 at 3:26 AM Alexander Neundorf <[email protected]> wrote: > > Hi, > > you may have noticed I'm catching up a bit... > > Do I understand correctly that kate starts clangd, and then when editing some > source file foo.cpp, it asks clangd for information about foo.cpp. > > clangd then tries to "compile" foo.cpp by executing a compile command, which > it tries to get from compile_commands.json. > For a file /home/alex/src/Project/foo.cpp, clangd searches for > compile_commands.json in /home/alex/src/Project/, /home/alex/src/, /home/ > alex/, /home/, / and /home/alex/src/Project/build/. Did I understand this > correctly ? (so this will often fail) > > IIRC, in the project plugin, we know if a file is part of a project, and the > project knows where the build and the source directories are. > So kate could point clangd to the top level build directory of the source > file. According to the clangd documentation it's currently not possible to > tell clangd where the compile_commands.json file is. Correct ? > > Then, in the compile_commands.json file, the calls to the actual compile are > listed, e.g. using g++. What does clangd do with them ? Simply skip the > compile executable and "hope" that clang understands the rest of the command > line ? > > Thanks > Alex > > >