@@ -24,8 +24,8 @@ use lsp_types::{
24
24
CodeAction , CodeActionCapability , CodeActionContext , CodeActionKind ,
25
25
CodeActionKindLiteralSupport , CodeActionLiteralSupport , CodeActionOrCommand , CodeActionParams ,
26
26
CodeActionResponse , CodeLens , Command , CompletionCapability , CompletionItem ,
27
- CompletionItemCapability , CompletionResponse , CompletionTextEdit , Diagnostic ,
28
- DiagnosticSeverity , DidChangeConfigurationParams , DidChangeTextDocumentParams ,
27
+ CompletionItemCapability , CompletionResponse , CompletionTextEdit , ConfigurationParams ,
28
+ Diagnostic , DiagnosticSeverity , DidChangeConfigurationParams , DidChangeTextDocumentParams ,
29
29
DidChangeWatchedFilesParams , DidChangeWatchedFilesRegistrationOptions ,
30
30
DidCloseTextDocumentParams , DidOpenTextDocumentParams , DidSaveTextDocumentParams ,
31
31
DocumentChangeOperation , DocumentChanges , DocumentFormattingParams , DocumentHighlight ,
@@ -1261,6 +1261,7 @@ impl LanguageClient {
1261
1261
} ) ,
1262
1262
workspace : Some ( WorkspaceClientCapabilities {
1263
1263
apply_edit : Some ( true ) ,
1264
+ configuration : Some ( true ) ,
1264
1265
did_change_watched_files : Some ( GenericCapability {
1265
1266
dynamic_registration : Some ( true ) ,
1266
1267
} ) ,
@@ -2045,6 +2046,27 @@ impl LanguageClient {
2045
2046
Ok ( ( ) )
2046
2047
}
2047
2048
2049
+ pub fn workspace_configuration ( & self , params : & Value ) -> Result < Value > {
2050
+ let config_params = ConfigurationParams :: deserialize ( params) ?;
2051
+
2052
+ let filename = self . vim ( ) ?. get_filename ( & Value :: Null ) ?;
2053
+ let language_id = self . vim ( ) ?. get_language_id ( & filename, & Value :: Null ) ?;
2054
+ let root = self . get ( |state| state. roots . get ( & language_id) . cloned ( ) . unwrap_or_default ( ) ) ?;
2055
+
2056
+ let settings = self . get_workspace_settings ( & root) ?;
2057
+
2058
+ let configuration_items = config_params
2059
+ . items
2060
+ . into_iter ( )
2061
+ . filter_map ( |item| {
2062
+ let section = format ! ( "/{}" , item. section?. replace( "." , "/" ) ) ;
2063
+ settings. pointer ( & section) . cloned ( )
2064
+ } )
2065
+ . collect :: < Value > ( ) ;
2066
+
2067
+ Ok ( configuration_items)
2068
+ }
2069
+
2048
2070
pub fn handle_code_lens_action ( & self , params : & Value ) -> Result < Value > {
2049
2071
let filename = self . vim ( ) ?. get_filename ( params) ?;
2050
2072
let line = self . vim ( ) ?. get_position ( params) ?. line ;
0 commit comments