I'm using some linux APIs for my study recently and had to read comments on kernel code. But some of my vim actions doesn't work as expected.
For example, I would like to read docstring of device_create which is written on drivers/base/core.c above device_create definition

but Neovim hover shows comment in the corresponding header file (which is include/linux/device.h) where the function is declared.

Also gd (go to definition) would not go to definition but goes to declaration.
Maybe vscode behaviors can give some hints for resolving.
In VSCode, in the beginning, it shows just like the neovim does.

but gd takes me to correct definition

and once I go to the definition, the hover results as expected.

Summary
- How can I make neovim show comments on definition when I hover (
K) ? - How can I make neovim go to the definition not the declaration when I
gd?
Environments
- neovim 0.9
- LSP: clangd
compile_commands.jsonis created
I was inspecting for this issue for a while and founded out that it was an issue in clangd parsing the linux source file.
move the entire project somewhere in the linux kernel source tree. (ex. under
toolsfolder) - which resolvesgd(goto definition) problemif hover still shows the comment in wrong place, go to the declaration of the function (ex.
device_createin my case) and remove the comment above temporarily.remove
.cacheand let clangd re-indexand finally! clangd shows me the comment I wanted in the c file.
So, it turns out that clangd takes precedence in showing comments above the declaration part.
Of course, I don't think this is the best solution yet.
Maybe configuring clangd to take higher precedence on comments starting with
/**(not/*) might fix this issue properly.Please tell me if there is a way to do so.