@@ -23,8 +23,8 @@ use lsp_types::{
23
23
CodeAction , CodeActionCapability , CodeActionContext , CodeActionKind ,
24
24
CodeActionKindLiteralSupport , CodeActionLiteralSupport , CodeActionOrCommand , CodeActionParams ,
25
25
CodeActionResponse , CodeLens , Command , CompletionCapability , CompletionItem ,
26
- CompletionItemCapability , CompletionResponse , CompletionTextEdit , Diagnostic ,
27
- DiagnosticSeverity , DidChangeConfigurationParams , DidChangeTextDocumentParams ,
26
+ CompletionItemCapability , CompletionResponse , CompletionTextEdit , ConfigurationParams ,
27
+ Diagnostic , DiagnosticSeverity , DidChangeConfigurationParams , DidChangeTextDocumentParams ,
28
28
DidChangeWatchedFilesParams , DidChangeWatchedFilesRegistrationOptions ,
29
29
DidCloseTextDocumentParams , DidOpenTextDocumentParams , DidSaveTextDocumentParams ,
30
30
DocumentChangeOperation , DocumentChanges , DocumentFormattingParams , DocumentHighlight ,
@@ -1235,6 +1235,7 @@ impl LanguageClient {
1235
1235
} ) ,
1236
1236
workspace : Some ( WorkspaceClientCapabilities {
1237
1237
apply_edit : Some ( true ) ,
1238
+ configuration : Some ( true ) ,
1238
1239
did_change_watched_files : Some ( GenericCapability {
1239
1240
dynamic_registration : Some ( true ) ,
1240
1241
} ) ,
@@ -2018,6 +2019,27 @@ impl LanguageClient {
2018
2019
Ok ( ( ) )
2019
2020
}
2020
2021
2022
+ pub fn workspace_configuration ( & self , params : & Value ) -> Result < Value > {
2023
+ let config_params = ConfigurationParams :: deserialize ( params) ?;
2024
+
2025
+ let filename = self . vim ( ) ?. get_filename ( & Value :: Null ) ?;
2026
+ let language_id = self . vim ( ) ?. get_language_id ( & filename, & Value :: Null ) ?;
2027
+ let root = self . get ( |state| state. roots . get ( & language_id) . cloned ( ) . unwrap_or_default ( ) ) ?;
2028
+
2029
+ let settings = self . get_workspace_settings ( & root) ?;
2030
+
2031
+ let configuration_items = config_params
2032
+ . items
2033
+ . into_iter ( )
2034
+ . filter_map ( |item| {
2035
+ let section = format ! ( "/{}" , item. section?. replace( "." , "/" ) ) ;
2036
+ settings. pointer ( & section) . cloned ( )
2037
+ } )
2038
+ . collect :: < Value > ( ) ;
2039
+
2040
+ Ok ( serde_json:: to_value ( & configuration_items) ?)
2041
+ }
2042
+
2021
2043
pub fn handle_code_lens_action ( & self , params : & Value ) -> Result < Value > {
2022
2044
let filename = self . vim ( ) ?. get_filename ( params) ?;
2023
2045
let line = self . vim ( ) ?. get_position ( params) ?. line ;
0 commit comments