@@ -43,8 +43,10 @@ use crate::lsp;
43
43
use crate :: lsp:: capabilities:: Capabilities ;
44
44
use crate :: lsp:: config:: indent_style_from_lsp;
45
45
use crate :: lsp:: config:: DocumentConfig ;
46
+ use crate :: lsp:: config:: SymbolsConfig ;
46
47
use crate :: lsp:: config:: VscDiagnosticsConfig ;
47
48
use crate :: lsp:: config:: VscDocumentConfig ;
49
+ use crate :: lsp:: config:: VscSymbolsConfig ;
48
50
use crate :: lsp:: diagnostics:: DiagnosticsConfig ;
49
51
use crate :: lsp:: documents:: Document ;
50
52
use crate :: lsp:: encoding:: get_position_encoding_kind;
@@ -244,6 +246,9 @@ pub(crate) async fn did_change_configuration(
244
246
// we should just ignore it. Instead we need to pull the settings again for
245
247
// all URI of interest.
246
248
249
+ // Note that the client sends notifications for settings for which we have
250
+ // declared interest in. This registration is done in `handle_initialized()`.
251
+
247
252
update_config ( workspace_uris ( state) , client, state)
248
253
. instrument ( tracing:: info_span!( "did_change_configuration" ) )
249
254
. await
@@ -296,6 +301,16 @@ async fn update_config(
296
301
. collect ( ) ;
297
302
items. append ( & mut diagnostics_items) ;
298
303
304
+ let symbols_keys = VscSymbolsConfig :: FIELD_NAMES_AS_ARRAY ;
305
+ let mut symbols_items: Vec < ConfigurationItem > = symbols_keys
306
+ . iter ( )
307
+ . map ( |key| ConfigurationItem {
308
+ scope_uri : None ,
309
+ section : Some ( VscSymbolsConfig :: section_from_key ( key) . into ( ) ) ,
310
+ } )
311
+ . collect ( ) ;
312
+ items. append ( & mut symbols_items) ;
313
+
299
314
// For document configs we collect all pairs of URIs and config keys of
300
315
// interest in a flat vector
301
316
let document_keys = VscDocumentConfig :: FIELD_NAMES_AS_ARRAY ;
@@ -316,7 +331,8 @@ async fn update_config(
316
331
// by chunk
317
332
let n_document_items = document_keys. len ( ) ;
318
333
let n_diagnostics_items = diagnostics_keys. len ( ) ;
319
- let n_items = n_diagnostics_items + ( n_document_items * uris. len ( ) ) ;
334
+ let n_symbols_items = symbols_keys. len ( ) ;
335
+ let n_items = n_diagnostics_items + n_symbols_items + ( n_document_items * uris. len ( ) ) ;
320
336
321
337
if configs. len ( ) != n_items {
322
338
return Err ( anyhow ! (
@@ -351,6 +367,19 @@ async fn update_config(
351
367
lsp:: spawn_diagnostics_refresh_all ( state. clone ( ) ) ;
352
368
}
353
369
370
+ // --- Symbols
371
+ let keys = symbols_keys. into_iter ( ) ;
372
+ let items: Vec < Value > = configs. by_ref ( ) . take ( n_symbols_items) . collect ( ) ;
373
+
374
+ let mut map = serde_json:: Map :: new ( ) ;
375
+ std:: iter:: zip ( keys, items) . for_each ( |( key, item) | {
376
+ map. insert ( key. into ( ) , item) ;
377
+ } ) ;
378
+
379
+ let config: VscSymbolsConfig = serde_json:: from_value ( serde_json:: Value :: Object ( map) ) ?;
380
+ let config: SymbolsConfig = config. into ( ) ;
381
+ state. config . symbols = config;
382
+
354
383
// --- Documents
355
384
// For each document, deserialise the vector of JSON values into a typed config
356
385
for uri in uris. into_iter ( ) {
0 commit comments