@@ -43,9 +43,9 @@ use lsp_types::{
4343 ShowMessageParams , ShowMessageRequestParams , SignatureHelp , SignatureHelpClientCapabilities ,
4444 SignatureInformationSettings , SymbolInformation , TextDocumentClientCapabilities ,
4545 TextDocumentContentChangeEvent , TextDocumentIdentifier , TextDocumentItem ,
46- TextDocumentPositionParams , TextEdit , UnregistrationParams , VersionedTextDocumentIdentifier ,
47- WorkDoneProgress , WorkDoneProgressParams , WorkspaceClientCapabilities , WorkspaceEdit ,
48- WorkspaceSymbolParams ,
46+ TextDocumentPositionParams , TextDocumentSyncCapability , TextDocumentSyncKind , TextEdit ,
47+ UnregistrationParams , VersionedTextDocumentIdentifier , WorkDoneProgress ,
48+ WorkDoneProgressParams , WorkspaceClientCapabilities , WorkspaceEdit , WorkspaceSymbolParams ,
4949} ;
5050use maplit:: hashmap;
5151use serde:: de:: Deserialize ;
@@ -2102,6 +2102,26 @@ impl LanguageClient {
21022102 pub fn text_document_did_save ( & self , params : & Value ) -> Result < ( ) > {
21032103 let filename = self . vim ( ) ?. get_filename ( params) ?;
21042104 let language_id = self . vim ( ) ?. get_language_id ( & filename, params) ?;
2105+ let has_capability = self . get_state ( |s| {
2106+ s. capabilities
2107+ . get ( & language_id)
2108+ . as_ref ( )
2109+ . map ( |i| match i. capabilities . text_document_sync . as_ref ( ) {
2110+ Some ( TextDocumentSyncCapability :: Kind ( TextDocumentSyncKind :: None ) ) => false ,
2111+ Some ( TextDocumentSyncCapability :: Kind ( _) ) => true ,
2112+ Some ( TextDocumentSyncCapability :: Options ( o) ) => match o. save {
2113+ Some ( lsp_types:: TextDocumentSyncSaveOptions :: Supported ( b) ) => b,
2114+ Some ( lsp_types:: TextDocumentSyncSaveOptions :: SaveOptions ( _) ) => true ,
2115+ None => false ,
2116+ } ,
2117+ None => false ,
2118+ } )
2119+ . unwrap_or_default ( )
2120+ } ) ?;
2121+ if !has_capability {
2122+ return Ok ( ( ) ) ;
2123+ }
2124+
21052125 if !self . get_config ( |c| c. server_commands . contains_key ( & language_id) ) ? {
21062126 return Ok ( ( ) ) ;
21072127 }
0 commit comments