@@ -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,9 +41,19 @@ impl Server {
4141
4242 let ( id, init_params) = connection. initialize_start ( ) ?;
4343
44+ let AllSettings {
45+ global_settings,
46+ mut workspace_settings,
47+ } = AllSettings :: from_value (
48+ init_params
49+ . initialization_options
50+ . unwrap_or_else ( || serde_json:: Value :: Object ( serde_json:: Map :: default ( ) ) ) ,
51+ ) ;
52+
4453 let client_capabilities = init_params. capabilities ;
4554 let position_encoding = Self :: find_best_position_encoding ( & client_capabilities) ;
46- let server_capabilities = Self :: server_capabilities ( position_encoding) ;
55+ let server_capabilities =
56+ Self :: server_capabilities ( position_encoding, global_settings. experimental . as_ref ( ) ) ;
4757
4858 let connection = connection. initialize_finish (
4959 id,
@@ -53,16 +63,6 @@ impl Server {
5363 ) ?;
5464
5565 crate :: message:: init_messenger ( connection. make_sender ( ) ) ;
56-
57- let AllSettings {
58- global_settings,
59- mut workspace_settings,
60- } = AllSettings :: from_value (
61- init_params
62- . initialization_options
63- . unwrap_or_else ( || serde_json:: Value :: Object ( serde_json:: Map :: default ( ) ) ) ,
64- ) ;
65-
6666 crate :: logging:: init_logging (
6767 global_settings. tracing . log_level . unwrap_or_default ( ) ,
6868 global_settings. tracing . log_file . as_deref ( ) ,
@@ -206,7 +206,10 @@ impl Server {
206206 . unwrap_or_default ( )
207207 }
208208
209- fn server_capabilities ( position_encoding : PositionEncoding ) -> ServerCapabilities {
209+ fn server_capabilities (
210+ position_encoding : PositionEncoding ,
211+ experimental : Option < & Experimental > ,
212+ ) -> ServerCapabilities {
210213 ServerCapabilities {
211214 position_encoding : Some ( position_encoding. into ( ) ) ,
212215 diagnostic_provider : Some ( DiagnosticServerCapabilities :: Options ( DiagnosticOptions {
@@ -226,9 +229,11 @@ impl Server {
226229 inlay_hint_provider : Some ( lsp_types:: OneOf :: Right (
227230 InlayHintServerCapabilities :: Options ( InlayHintOptions :: default ( ) ) ,
228231 ) ) ,
229- completion_provider : Some ( lsp_types:: CompletionOptions {
230- ..Default :: default ( )
231- } ) ,
232+ completion_provider : experimental
233+ . is_some_and ( Experimental :: is_completions_enabled)
234+ . then_some ( lsp_types:: CompletionOptions {
235+ ..Default :: default ( )
236+ } ) ,
232237 ..Default :: default ( )
233238 }
234239 }
0 commit comments