@@ -18,8 +18,6 @@ use stdext::result::ResultExt;
1818use tower_lsp:: lsp_types;
1919use tower_lsp:: lsp_types:: CompletionOptions ;
2020use tower_lsp:: lsp_types:: CompletionOptionsCompletionItem ;
21- use tower_lsp:: lsp_types:: CreateFilesParams ;
22- use tower_lsp:: lsp_types:: DeleteFilesParams ;
2321use tower_lsp:: lsp_types:: DidChangeConfigurationParams ;
2422use tower_lsp:: lsp_types:: DidChangeTextDocumentParams ;
2523use tower_lsp:: lsp_types:: DidChangeWatchedFilesParams ;
@@ -29,18 +27,13 @@ use tower_lsp::lsp_types::DidOpenTextDocumentParams;
2927use tower_lsp:: lsp_types:: DocumentOnTypeFormattingOptions ;
3028use tower_lsp:: lsp_types:: ExecuteCommandOptions ;
3129use tower_lsp:: lsp_types:: FileChangeType ;
32- use tower_lsp:: lsp_types:: FileOperationFilter ;
33- use tower_lsp:: lsp_types:: FileOperationPattern ;
34- use tower_lsp:: lsp_types:: FileOperationPatternKind ;
35- use tower_lsp:: lsp_types:: FileOperationRegistrationOptions ;
3630use tower_lsp:: lsp_types:: FoldingRangeProviderCapability ;
3731use tower_lsp:: lsp_types:: FormattingOptions ;
3832use tower_lsp:: lsp_types:: HoverProviderCapability ;
3933use tower_lsp:: lsp_types:: ImplementationProviderCapability ;
4034use tower_lsp:: lsp_types:: InitializeParams ;
4135use tower_lsp:: lsp_types:: InitializeResult ;
4236use tower_lsp:: lsp_types:: OneOf ;
43- use tower_lsp:: lsp_types:: RenameFilesParams ;
4437use tower_lsp:: lsp_types:: RenameOptions ;
4538use tower_lsp:: lsp_types:: SelectionRangeProviderCapability ;
4639use tower_lsp:: lsp_types:: ServerCapabilities ;
@@ -200,28 +193,11 @@ pub(crate) fn initialize(
200193 supported : Some ( true ) ,
201194 change_notifications : Some ( OneOf :: Left ( true ) ) ,
202195 } ) ,
203- file_operations : {
204- let r_file_filter = FileOperationFilter {
205- scheme : Some ( String :: from ( "file" ) ) ,
206- pattern : FileOperationPattern {
207- glob : String :: from ( "**/*.{r,R}" ) ,
208- matches : Some ( FileOperationPatternKind :: File ) ,
209- options : None ,
210- } ,
211- } ;
212- Some ( lsp_types:: WorkspaceFileOperationsServerCapabilities {
213- did_create : Some ( FileOperationRegistrationOptions {
214- filters : vec ! [ r_file_filter. clone( ) ] ,
215- } ) ,
216- did_delete : Some ( FileOperationRegistrationOptions {
217- filters : vec ! [ r_file_filter. clone( ) ] ,
218- } ) ,
219- did_rename : Some ( FileOperationRegistrationOptions {
220- filters : vec ! [ r_file_filter] ,
221- } ) ,
222- ..Default :: default ( )
223- } )
224- } ,
196+ // We don't register `file_operations`. Disk changes reach us
197+ // through `didChangeWatchedFiles` from every source (editor, git,
198+ // terminal), so it's the single channel that keeps the index
199+ // current. A rename arrives there as delete + create.
200+ file_operations : None ,
225201 } ) ,
226202 document_on_type_formatting_provider : Some ( DocumentOnTypeFormattingOptions {
227203 first_trigger_character : String :: from ( "\n " ) ,
@@ -336,54 +312,24 @@ pub(crate) fn did_close(
336312 Ok ( ( ) )
337313}
338314
339- #[ tracing:: instrument( level = "info" , skip_all) ]
340- pub ( crate ) fn did_create_files (
341- _params : CreateFilesParams ,
342- _state : & WorldState ,
343- ) -> anyhow:: Result < ( ) > {
344- Ok ( ( ) )
345- }
346-
347- #[ tracing:: instrument( level = "info" , skip_all) ]
348- pub ( crate ) fn did_delete_files (
349- _params : DeleteFilesParams ,
350- _state : & WorldState ,
351- ) -> anyhow:: Result < ( ) > {
352- Ok ( ( ) )
353- }
354-
355- #[ tracing:: instrument( level = "info" , skip_all) ]
356- pub ( crate ) fn did_rename_files (
357- _params : RenameFilesParams ,
358- _state : & mut WorldState ,
359- ) -> anyhow:: Result < ( ) > {
360- Ok ( ( ) )
361- }
362-
363315#[ tracing:: instrument( level = "info" , skip_all) ]
364316pub ( crate ) fn did_change_watched_files (
365317 params : DidChangeWatchedFilesParams ,
366318 state : & mut WorldState ,
367319 lsp_state : & mut LspState ,
368320 events_tx : & TokioUnboundedSender < Event > ,
369321) -> anyhow:: Result < ( ) > {
370- // Editor owns the contents of files it has open: Oak should ignore
371- // disk-side events for those URLs.
322+ // Editor owns the contents of files it has open: ignore disk-side events
323+ // for those URLs. Their content comes from `did_open` / `did_change` .
372324 let editor_owned: HashSet < FilePath > = state. documents . keys ( ) . cloned ( ) . collect ( ) ;
373325
374326 let events: Vec < FileEvent > = params
375327 . changes
376- . into_iter ( )
377- . filter_map ( |e| {
378- let kind = match e. typ {
379- FileChangeType :: CREATED => FileEventKind :: Created ,
380- FileChangeType :: CHANGED => FileEventKind :: Changed ,
381- FileChangeType :: DELETED => FileEventKind :: Deleted ,
382- _ => return None ,
383- } ;
328+ . iter ( )
329+ . filter_map ( |change| {
384330 Some ( FileEvent {
385- path : FilePath :: from_url ( & e . uri ) ,
386- kind,
331+ path : FilePath :: from_url ( & change . uri ) ,
332+ kind : file_event_kind ( change . typ ) ? ,
387333 } )
388334 } )
389335 . collect ( ) ;
@@ -393,9 +339,19 @@ pub(crate) fn did_change_watched_files(
393339 . oak_scheduler
394340 . apply_watcher_events ( & mut state. db , events, & editor_owned) ;
395341 dispatch_scan_requests ( events_tx, requests) ;
342+
396343 Ok ( ( ) )
397344}
398345
346+ fn file_event_kind ( kind : FileChangeType ) -> Option < FileEventKind > {
347+ match kind {
348+ FileChangeType :: CREATED => Some ( FileEventKind :: Created ) ,
349+ FileChangeType :: CHANGED => Some ( FileEventKind :: Changed ) ,
350+ FileChangeType :: DELETED => Some ( FileEventKind :: Deleted ) ,
351+ _ => None ,
352+ }
353+ }
354+
399355#[ tracing:: instrument( level = "info" , skip_all) ]
400356pub ( crate ) fn did_change_workspace_folders (
401357 params : DidChangeWorkspaceFoldersParams ,
0 commit comments