Problem
I installed ftxui into my CMake managed project using canon, and I'm using vscode-clangd (I'll call it clangd) as the LSP. However, I found that clangd provided "hover to view document" to be "not useful" and go to implementation "founds none".
After some research I found that the author of ftxui split their source code into hpp (declaration) and cpp (implementation) files, but the actual docs are written in the cpp files. And conan stores them in different locations: cpps are under ~/.conan2/p/b/ftxuif8e789ccd8656/b/src/src/ftxui and hpps are under ~/.conan2/p/b/ftxuif8e789ccd8656/b/src/include/ftxui. However, clangd used ~/.conan2/p/b/ftxuif8e789ccd8656/p/include/ftxui to provide docs and completions and all I found under this dir are hpps. But I noticed that ~/.conan2/p/b/ftxuif8e789ccd8656/p/lib stores some compiled libraries with .a as their file extension.
I assumed the string after ftxui to be hash, because I downloaded the library several times and found several different dirs with same prefix.
Expectation
I would like clangd to provide the actual documentation written in the cpp files when I hover over an item, and it being able to perform "go to implementation". Or, if this it not possible, understand why and knows where to open an issue (or accept the fact).
Supplementary
As far as I know, clangd uses the compile_commands.json generated by CMake to provide IntelliSense, do I need to set some CMake build flags?
- The project I have question with (just a starter project copied from the tutorial)
- I'm using Ubuntu 22.04, Conan v2.1.0, CMake v3.28.3, clangd v18.1.2 and gcc v11.4.0
- My VSCode uses clangd as the LSP and have disabled cpptools plugin.
Misc
I'm unsure if this is a problem of mine, or clangd (or vscode-clangd), or conan, or the library author. So any guidance, help and clarification would be greatly appreciated.
Two things would be needed to get this to work:
Clangd needs to know where the source files of the library are. This basically means, the
compile_commands.jsonfile for your project needs to have entries for files such as, for example,ftxui/src/ftxui/dom /linear_gradient.cpp. This probably doesn't happen by default, but you could make it happen with a bit of work:compile_commands.jsonfor the ftxui sources.compile_commands.jsoninto your project'scompile_commands.json(or just copy the entries from one to the other manually).Clangd needs to show hover information from comments in implementation files. This is currently a missing feature of clangd, however there is an open PR for it: https://github.com/llvm/llvm-project/pull/67802. So it could get this feature soon.