Recommended LSP independent API?

Hello folks, I'm looking for a way to access Rust Analyzer without LSP.

AFAIK, RA is designed to be independent from LSP. IMO, the intended "native" API is ra_ide::AnalysisHost. And it seems I have to perform all file I/O and dependency discovery myself. GlobalState in rust_analyzer crate seems doing the jobs, but it is coupled with LSP.

This makes me somewhat confused. Is that AnalysisHost a correct place to start? Or is there something else?

Yes, AnalysisHost is the right place. The fact that it doesn’t do IO is a feature :-). You can use project_model crate to do dependency discovery (see how stuff in cli module works).


Thanks. I think separated I/O is a very good design. I'll take a look of project_model.

Got to the bigger screen :slight_smile:

So this is an example code which creates AnalysisHost directly, without going via GlobalState:

The bulk of work happens here:

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.