MCPcopy Create free account
hub / github.com/PRQL/prql / run

Function run

prqlc/prqlc/src/cli/lsp.rs:10–39  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

8use lsp_server::{Connection, ExtractError, Message, Request, RequestId, Response};
9
10pub fn run() -> Result<(), Box<dyn Error + Sync + Send>> {
11 // Note that we must have our logging only write out to stderr.
12 eprintln!("starting PRQL LSP server");
13
14 // Create the transport. Includes the stdio (stdin and stdout) versions but this could
15 // also be implemented to use sockets or HTTP.
16 let (connection, io_threads) = Connection::stdio();
17
18 // Run the server and wait for the two threads to end (typically by trigger LSP Exit event).
19 let server_capabilities = serde_json::to_value(&ServerCapabilities {
20 definition_provider: Some(OneOf::Left(true)),
21 ..Default::default()
22 })
23 .unwrap();
24 let initialization_params = match connection.initialize(server_capabilities) {
25 Ok(it) => it,
26 Err(e) => {
27 if e.channel_is_disconnected() {
28 io_threads.join()?;
29 }
30 return Err(e.into());
31 }
32 };
33 main_loop(connection, initialization_params)?;
34 io_threads.join()?;
35
36 // Shut down gracefully.
37 eprintln!("shutting down server");
38 Ok(())
39}
40
41fn main_loop(
42 connection: Connection,

Callers 2

runMethod · 0.70
test-prql.jsFile · 0.50

Calls 1

main_loopFunction · 0.85

Tested by

no test coverage detected