Clangd error: trying to get AST for non-added document

Anyone ever get this error and fix it.
There was mention of it on the clang git but unsure what actions i could take to solve it for myself

they mention getting this error if the file hasn’t been opened or if you opened and then closed the file. does this mean you can only have a decent experience with lsp only after opening all your project files? that seems odd.

i use bufferline buffers-as-tabs style of displaying what files i have open. also i will kill the old cpp/h when toggling between header and cpp to clean up teh bufferline. I do notice that when i do that and try a goto def it takes a bit to re-index or do whatever it needs to do before finding where that def is.

guessing with cpp lsp i should probably switch back to tabs and keep buffers open, regardless of this error.

I get this error after i use the lsp’s formatter and then do something like goto def. all lsp functionality is broken after format, but only for the file that was just formatted. have to :LspRestart after formatting.

the error looks like this:

does this have anything to do with treesitter? is formatting the file causing it (the “document”?) to become “non-added”? how would i re-add it?

FWIW I just ran format on main.c in the neovim source code and goto-definition worked fine, so I can’t reproduce.

good to know, hopefully something in my config then.
i can add the document back with :e

probably doesn’t matter but im on windows 10 using the llvm from winget install llvm which is version 13

I tried on mac/linux (sorry, not a windows user), hopefully a windows users can try to reproduce the problem and file a PR if there is an issue :slight_smile: