1
1
use log:: info;
2
2
use lsp_server:: { Connection , Message } ;
3
3
use lsp_types:: { InitializeParams , ServerCapabilities } ;
4
- use std:: error:: Error ;
5
4
6
- pub fn run ( ) -> Result < ( ) , Box < dyn Error > > {
5
+ pub fn run ( ) -> anyhow :: Result < ( ) > {
7
6
// Set up logging. Because `stdio_transport` gets a lock on stdout and stdin, we must have
8
7
// our logging only write out to stderr.
9
- flexi_logger:: Logger :: with_str ( "info" ) . start ( ) . unwrap ( ) ;
8
+ flexi_logger:: Logger :: with_str ( "info" ) . start ( ) ? ;
10
9
info ! ( "Starting Pikelet LSP server" ) ;
11
10
12
11
// Create the transport. Includes the stdio (stdin and stdout) versions but this could
13
12
// also be implemented to use sockets or HTTP.
14
13
let ( connection, io_threads) = Connection :: stdio ( ) ;
15
14
16
15
// Run the server and wait for the two threads to end (typically by trigger LSP Exit event).
17
- let server_capabilities = serde_json:: to_value ( & ServerCapabilities :: default ( ) ) . unwrap ( ) ;
16
+ let server_capabilities = serde_json:: to_value ( & ServerCapabilities :: default ( ) ) ? ;
18
17
let initialization_params = connection. initialize ( server_capabilities) ?;
19
18
main_loop ( & connection, initialization_params) ?;
20
19
io_threads. join ( ) ?;
@@ -25,7 +24,7 @@ pub fn run() -> Result<(), Box<dyn Error>> {
25
24
Ok ( ( ) )
26
25
}
27
26
28
- fn main_loop ( connection : & Connection , params : serde_json:: Value ) -> Result < ( ) , Box < dyn Error > > {
27
+ fn main_loop ( connection : & Connection , params : serde_json:: Value ) -> anyhow :: Result < ( ) > {
29
28
let _params: InitializeParams = serde_json:: from_value ( params) . unwrap ( ) ;
30
29
31
30
info ! ( "Starting Pikelet main loop" ) ;
0 commit comments