11use std:: {
2- collections:: { HashMap , HashSet } ,
2+ collections:: HashSet ,
33 sync:: { Arc , Mutex } ,
44} ;
55
66use tower_lsp:: {
77 Client , LanguageServer ,
88 lsp_types:: {
9- CompletionOptions , DidOpenTextDocumentParams , HoverProviderCapability , InitializeParams ,
10- InitializeResult , InitializedParams , MessageType , ServerCapabilities , ServerInfo ,
11- TextDocumentSyncCapability , TextDocumentSyncKind ,
9+ DidChangeTextDocumentParams , DidOpenTextDocumentParams , InitializeParams , InitializeResult ,
10+ MessageType , ServerCapabilities , ServerInfo , TextDocumentSyncCapability ,
11+ TextDocumentSyncKind ,
1212 } ,
1313} ;
1414
@@ -28,8 +28,8 @@ impl LanguageServer for LSPBackend {
2828 ) -> tower_lsp:: jsonrpc:: Result < InitializeResult > {
2929 Ok ( InitializeResult {
3030 capabilities : ServerCapabilities {
31- hover_provider : Some ( HoverProviderCapability :: Simple ( true ) ) ,
32- completion_provider : Some ( CompletionOptions :: default ( ) ) ,
31+ hover_provider : None ,
32+ completion_provider : None ,
3333 text_document_sync : Some ( TextDocumentSyncCapability :: Kind (
3434 TextDocumentSyncKind :: FULL ,
3535 ) ) ,
@@ -50,14 +50,31 @@ impl LanguageServer for LSPBackend {
5050
5151 let mut diags = vec ! [ ] ;
5252
53+ for diag in check_for_file ( uri. clone ( ) . replace ( "file://" , "" ) , text. clone ( ) ) {
54+ diags. push ( to_tower_diag ( diag) )
55+ }
56+
57+ self . lsp_client . log_message ( MessageType :: ERROR , text) . await ;
58+
5359 self . lsp_client
54- . log_message ( MessageType :: ERROR , format ! ( "Path: {}" , uri ) )
60+ . publish_diagnostics ( uri . parse ( ) . unwrap ( ) , diags , None )
5561 . await ;
62+ }
5663
57- for diag in check_for_file ( uri. clone ( ) . replace ( "file://" , "" ) ) {
64+ async fn did_change ( & self , params : DidChangeTextDocumentParams ) {
65+ let uri = params. text_document . uri . to_string ( ) ;
66+ let text = params. content_changes [ 0 ] . text . clone ( ) ;
67+
68+ self . documents . lock ( ) . unwrap ( ) . insert ( uri. clone ( ) ) ;
69+
70+ let mut diags = vec ! [ ] ;
71+
72+ for diag in check_for_file ( uri. clone ( ) . replace ( "file://" , "" ) , text. clone ( ) ) {
5873 diags. push ( to_tower_diag ( diag) )
5974 }
6075
76+ self . lsp_client . log_message ( MessageType :: ERROR , text) . await ;
77+
6178 self . lsp_client
6279 . publish_diagnostics ( uri. parse ( ) . unwrap ( ) , diags, None )
6380 . await ;
0 commit comments