@@ -15,7 +15,7 @@ use lsp_types::{
1515
1616use self :: connection:: { Connection , ConnectionInitializer } ;
1717use self :: schedule:: event_loop_thread;
18- use crate :: session:: { AllSettings , ClientSettings , Session } ;
18+ use crate :: session:: { AllSettings , ClientSettings , Experimental , Session } ;
1919use crate :: PositionEncoding ;
2020
2121mod api;
@@ -41,19 +41,6 @@ impl Server {
4141
4242 let ( id, init_params) = connection. initialize_start ( ) ?;
4343
44- let client_capabilities = init_params. capabilities ;
45- let position_encoding = Self :: find_best_position_encoding ( & client_capabilities) ;
46- let server_capabilities = Self :: server_capabilities ( position_encoding) ;
47-
48- let connection = connection. initialize_finish (
49- id,
50- & server_capabilities,
51- crate :: SERVER_NAME ,
52- crate :: version ( ) ,
53- ) ?;
54-
55- crate :: message:: init_messenger ( connection. make_sender ( ) ) ;
56-
5744 let AllSettings {
5845 global_settings,
5946 mut workspace_settings,
@@ -68,6 +55,20 @@ impl Server {
6855 global_settings. tracing . log_file . as_deref ( ) ,
6956 ) ;
7057
58+ let client_capabilities = init_params. capabilities ;
59+ let position_encoding = Self :: find_best_position_encoding ( & client_capabilities) ;
60+ let server_capabilities =
61+ Self :: server_capabilities ( position_encoding, global_settings. experimental . as_ref ( ) ) ;
62+
63+ let connection = connection. initialize_finish (
64+ id,
65+ & server_capabilities,
66+ crate :: SERVER_NAME ,
67+ crate :: version ( ) ,
68+ ) ?;
69+
70+ crate :: message:: init_messenger ( connection. make_sender ( ) ) ;
71+
7172 let mut workspace_for_url = |url : Url | {
7273 let Some ( workspace_settings) = workspace_settings. as_mut ( ) else {
7374 return ( url, ClientSettings :: default ( ) ) ;
@@ -206,7 +207,10 @@ impl Server {
206207 . unwrap_or_default ( )
207208 }
208209
209- fn server_capabilities ( position_encoding : PositionEncoding ) -> ServerCapabilities {
210+ fn server_capabilities (
211+ position_encoding : PositionEncoding ,
212+ experimental : Option < & Experimental > ,
213+ ) -> ServerCapabilities {
210214 ServerCapabilities {
211215 position_encoding : Some ( position_encoding. into ( ) ) ,
212216 diagnostic_provider : Some ( DiagnosticServerCapabilities :: Options ( DiagnosticOptions {
@@ -226,9 +230,11 @@ impl Server {
226230 inlay_hint_provider : Some ( lsp_types:: OneOf :: Right (
227231 InlayHintServerCapabilities :: Options ( InlayHintOptions :: default ( ) ) ,
228232 ) ) ,
229- completion_provider : Some ( lsp_types:: CompletionOptions {
230- ..Default :: default ( )
231- } ) ,
233+ completion_provider : experimental
234+ . is_some_and ( Experimental :: enable_completions)
235+ . then_some ( lsp_types:: CompletionOptions {
236+ ..Default :: default ( )
237+ } ) ,
232238 ..Default :: default ( )
233239 }
234240 }
0 commit comments