I'm running into an awkward bug with lsp-mode
+ clangd
for batch editing files.
When a source file is loaded, the symbols it points to aren't immediately available (using xref-find-definitions
for example).
Calling xref-find-definitions
fails on a newly loaded buffer.
Adding a sleep timer: e.g: (sleep-for 3.0)
then calling xref-find-definitions
works as expected (showing the header for an implementation of a function for example).
How can this be handled more reliably than sleeping and hoping the file references have loaded?
For reference
This is a stand-alone, single-file script that uses emacs+lsp, with a
FIXME
comment around the sleep call. https://gitlab.com/ideasman42/emacs-relocate-docsthis-package fails to work when the
doc-show-inline-idle-delay-init
is set to zero.
lsp-find-definition
, bounded to<s-l> gg
- is that also slow? (without sleep).LSP :: Connected to [clangd:57835/starting]. Debugger entered--Lisp error: (error "The connected server(s) does not support method te...") error("The connected server(s) does not support method %s..." "textDocument/definition") lsp--send-request-async((:jsonrpc "2.0" :method "textDocument/definition" :params
As wirh xref, calling(sleep-for 3.0)
beforehand solves.lsp
version do you have? Also, do you use cmake to have acompile_command.json
file? Maybe posting some parts of your configuration will help. Thelsp-mode
uses part of xref core, not xref itself. A lag could be normal, until the file is indexed.exec-path
- should containclangd
's path.