emacs-lsp / emacs-ccls

Emacs client for ccls, a C/C++ language server
200 stars 29 forks source link

Changes to header not registering in cpp file #41

Closed lane-s closed 5 years ago

lane-s commented 5 years ago

If I have a header file and a cpp file open at the same time and add a function prototype to the header, I would expect to be able to write the function implementation in the cpp buffer without any errors.

However, usually I get the message that the function I'm implementing is not defined. Sometimes saving both files seems to trigger everything to refresh, but otherwise the only way I know how to fix it is by restarting the lsp workspace.

Any idea what's causing this? I'm not sure if it's a problem with emacs-ccls or lsp-mode in general, but I figured I'd ask here first. Thanks

MaskRay commented 5 years ago
// a.cc
#include "a.h"
int main() { foo(); }
// a.h
// empty

There is "use of undeclared identifier 'foo'" error message published by textDocument/publishDiagnostics. Then, if you put void foo(); into a.h and make an edit in a.cc, the edit causes the client (lsp-mode) to send a textDocument/didChange notification to the ccls server. ccls will thereby send an empty textDocument/publishDiagnostics to indicate the error has been fixed.

Sometimes there may be lingering diagnostics, but that is probably lsp-ui-flycheck (or flycheck) or flymake's problem.

lane-s commented 5 years ago

Thank you. Now that I know what to look for in the logs, it seems the empty publishDiagnostics message is being sent, so the problem is with lsp-ui.

MaskRay commented 5 years ago

If you use lsp-ui-flycheck, see https://github.com/emacs-lsp/lsp-ui/pull/214