@@ -9,8 +9,8 @@ use async_lsp::lsp_types::{
9
9
DocumentSymbolResponse , FileOperationFilter , FileOperationPattern , FileOperationPatternKind ,
10
10
FileOperationRegistrationOptions , GotoDefinitionParams , GotoDefinitionResponse , Hover ,
11
11
HoverContents , HoverParams , HoverProviderCapability , InitializeParams , InitializeResult , OneOf ,
12
- PrepareRenameResponse , RenameFilesParams , RenameParams , ServerCapabilities , ServerInfo ,
13
- TextDocumentPositionParams , TextDocumentSyncCapability , TextDocumentSyncKind , Url ,
12
+ PrepareRenameResponse , RenameFilesParams , RenameOptions , RenameParams , ServerCapabilities ,
13
+ ServerInfo , TextDocumentPositionParams , TextDocumentSyncCapability , TextDocumentSyncKind , Url ,
14
14
WorkspaceEdit , WorkspaceFileOperationsServerCapabilities , WorkspaceFoldersServerCapabilities ,
15
15
WorkspaceServerCapabilities ,
16
16
} ;
@@ -71,6 +71,21 @@ impl LanguageServer for ProtoLanguageServer {
71
71
} )
72
72
}
73
73
74
+ let mut rename_provider: OneOf < bool , RenameOptions > = OneOf :: Left ( true ) ;
75
+
76
+ if params
77
+ . capabilities
78
+ . text_document
79
+ . and_then ( |cap| cap. rename )
80
+ . and_then ( |r| r. prepare_support )
81
+ . unwrap_or_default ( )
82
+ {
83
+ rename_provider = OneOf :: Right ( RenameOptions {
84
+ prepare_provider : Some ( true ) ,
85
+ work_done_progress_options : Default :: default ( ) ,
86
+ } )
87
+ }
88
+
74
89
let response = InitializeResult {
75
90
capabilities : ServerCapabilities {
76
91
// todo(): We might prefer incremental sync at some later stage
@@ -82,7 +97,7 @@ impl LanguageServer for ProtoLanguageServer {
82
97
hover_provider : Some ( HoverProviderCapability :: Simple ( true ) ) ,
83
98
document_symbol_provider : Some ( OneOf :: Left ( true ) ) ,
84
99
completion_provider : Some ( CompletionOptions :: default ( ) ) ,
85
- rename_provider : Some ( OneOf :: Left ( true ) ) ,
100
+ rename_provider : Some ( rename_provider ) ,
86
101
87
102
..ServerCapabilities :: default ( )
88
103
} ,
@@ -173,6 +188,7 @@ impl LanguageServer for ProtoLanguageServer {
173
188
} ;
174
189
175
190
let response = tree. can_rename ( & pos) . map ( PrepareRenameResponse :: Range ) ;
191
+
176
192
Box :: pin ( async move { Ok ( response) } )
177
193
}
178
194
0 commit comments