vim-lsp
vim-lsp copied to clipboard
Why :LspDeclaration and :LspDefinition go to the same place?
I am using vim-lsp and clangd to edit my C++ program.
When searching the definition of a member function of a class, :LspDeclaration and :LspDefinition go to the declaration of the member function. How can i go to the definition of the function?
#include <iostream>
class A {
public:
A() {}
void foo(); // LspDeclaration
};
void A::foo() { // LspDefinition
std::cout << "Hello, World!" << std::endl;
}
int main() {
A a;
a.foo(); // Current cursor line
return 0;
}
:LspDeclaration: Should jump to the declaration of foo(), which is the forward declaration inside the class A block: void foo();. :LspDefinition: Should jump to the definition (implementation) of foo(), which is the full function body: void A::foo() { std::cout << "Hello, World!" << std::endl; }.