@@ -8,7 +8,7 @@ use crossbeam_channel::{select, unbounded, Receiver, RecvError, Sender};
88use gen_lsp_server:: {
99 handle_shutdown, ErrorCode , RawMessage , RawNotification , RawRequest , RawResponse ,
1010} ;
11- use lsp_types:: NumberOrString ;
11+ use lsp_types:: { ClientCapabilities , NumberOrString } ;
1212use ra_ide_api:: { Canceled , FileId , LibraryData } ;
1313use ra_prof:: profile;
1414use ra_vfs:: VfsTask ;
@@ -22,7 +22,7 @@ use crate::{
2222 } ,
2323 project_model:: workspace_loader,
2424 req,
25- world:: { WorldSnapshot , WorldState } ,
25+ world:: { Options , WorldSnapshot , WorldState } ,
2626 InitializationOptions , Result ,
2727} ;
2828
@@ -51,6 +51,7 @@ impl Error for LspError {}
5151
5252pub fn main_loop (
5353 ws_roots : Vec < PathBuf > ,
54+ client_caps : ClientCapabilities ,
5455 options : InitializationOptions ,
5556 msg_receiver : & Receiver < RawMessage > ,
5657 msg_sender : & Sender < RawMessage > ,
@@ -77,15 +78,27 @@ pub fn main_loop(
7778 loaded_workspaces
7879 } ;
7980
80- let mut state = WorldState :: new ( ws_roots, workspaces, options. lru_capacity ) ;
81+ let mut state = WorldState :: new (
82+ ws_roots,
83+ workspaces,
84+ options. lru_capacity ,
85+ Options {
86+ publish_decorations : options. publish_decorations ,
87+ show_workspace_loaded : options. show_workspace_loaded ,
88+ supports_location_link : client_caps
89+ . text_document
90+ . and_then ( |it| it. definition )
91+ . and_then ( |it| it. link_support )
92+ . unwrap_or ( false ) ,
93+ } ,
94+ ) ;
8195
8296 let pool = ThreadPool :: new ( THREADPOOL_SIZE ) ;
8397 let ( task_sender, task_receiver) = unbounded :: < Task > ( ) ;
8498 let mut pending_requests = PendingRequests :: default ( ) ;
8599
86100 log:: info!( "server initialized, serving requests" ) ;
87101 let main_res = main_loop_inner (
88- options,
89102 & pool,
90103 msg_sender,
91104 msg_receiver,
@@ -159,7 +172,6 @@ impl fmt::Debug for Event {
159172}
160173
161174fn main_loop_inner (
162- options : InitializationOptions ,
163175 pool : & ThreadPool ,
164176 msg_sender : & Sender < RawMessage > ,
165177 msg_receiver : & Receiver < RawMessage > ,
@@ -258,7 +270,7 @@ fn main_loop_inner(
258270 && in_flight_libraries == 0
259271 {
260272 let n_packages: usize = state. workspaces . iter ( ) . map ( |it| it. count ( ) ) . sum ( ) ;
261- if options. show_workspace_loaded {
273+ if state . options . show_workspace_loaded {
262274 let msg = format ! ( "workspace loaded, {} rust packages" , n_packages) ;
263275 show_message ( req:: MessageType :: Info , msg, msg_sender) ;
264276 }
@@ -270,7 +282,7 @@ fn main_loop_inner(
270282 update_file_notifications_on_threadpool (
271283 pool,
272284 state. snapshot ( ) ,
273- options. publish_decorations ,
285+ state . options . publish_decorations ,
274286 task_sender. clone ( ) ,
275287 subs. subscriptions ( ) ,
276288 )
0 commit comments