Nvm, I tried many different ways and it came out that we just need a time.sleep(0.5)before(or after i forgot) every textDocument/definition is called. The problem is fixed but the way clangd acted is very weird.