@@ -15,6 +15,7 @@ use crate::workspace::EditorWorkspaces;
1515
1616mod audio;
1717mod color;
18+ mod completion;
1819mod config;
1920mod diag_manager;
2021mod files;
@@ -59,6 +60,19 @@ impl LanguageServer for Backend {
5960 work_done_progress : None ,
6061 } ,
6162 } ) ,
63+ completion_provider : Some ( CompletionOptions {
64+ resolve_provider : Some ( false ) ,
65+ trigger_characters : Some ( vec ! [
66+ "(" . to_string( ) ,
67+ "," . to_string( ) ,
68+ "\\ " . to_string( ) ,
69+ ] ) ,
70+ all_commit_characters : None ,
71+ work_done_progress_options : WorkDoneProgressOptions {
72+ work_done_progress : None ,
73+ } ,
74+ completion_item : None ,
75+ } ) ,
6276 definition_provider : Some ( OneOf :: Left ( true ) ) ,
6377 color_provider : Some ( ColorProviderCapability :: Options (
6478 StaticTextDocumentColorProviderOptions {
@@ -110,7 +124,6 @@ impl LanguageServer for Backend {
110124 }
111125
112126 async fn did_change_watched_files ( & self , params : DidChangeWatchedFilesParams ) {
113- debug ! ( "did_change_watched_files" ) ;
114127 for x in params. changes {
115128 if x. uri . path ( ) . contains ( ".toml" ) {
116129 ConfigAnalyzer :: get ( )
@@ -124,7 +137,6 @@ impl LanguageServer for Backend {
124137 }
125138
126139 async fn did_open ( & self , params : DidOpenTextDocumentParams ) {
127- debug ! ( "did_open: {:?}" , params. text_document. uri) ;
128140 let document = TextDocumentItem {
129141 uri : params. text_document . uri . clone ( ) ,
130142 text : TextInformation :: Full ( & params. text_document . text ) ,
@@ -151,7 +163,6 @@ impl LanguageServer for Backend {
151163 }
152164
153165 async fn did_save ( & self , params : DidSaveTextDocumentParams ) {
154- debug ! ( "did_save: {:?}" , params. text_document. uri) ;
155166 ConfigAnalyzer :: get ( )
156167 . on_save ( params. text_document . uri . clone ( ) , self . client . clone ( ) )
157168 . await ;
@@ -170,7 +181,6 @@ impl LanguageServer for Backend {
170181 }
171182
172183 async fn did_close ( & self , params : DidCloseTextDocumentParams ) {
173- debug ! ( "did_close: {:?}" , params. text_document. uri) ;
174184 FileCache :: get ( ) . on_close ( & params. text_document . uri ) . await ;
175185 SqfAnalyzer :: get ( ) . on_close ( & params. text_document . uri ) . await ;
176186 PreprocessorAnalyzer :: get ( )
@@ -208,6 +218,16 @@ impl LanguageServer for Backend {
208218 ) -> Result < Vec < ColorPresentation > > {
209219 color:: presentation ( params) . await
210220 }
221+
222+ async fn completion ( & self , params : CompletionParams ) -> Result < Option < CompletionResponse > > {
223+ let uri = & params. text_document_position . text_document . uri ;
224+ let ( _, ext) = uri. path ( ) . rsplit_once ( '.' ) . unwrap_or ( ( uri. path ( ) , "" ) ) ;
225+ let ext = ext. to_lowercase ( ) ;
226+ if [ "sqf" , "ext" , "cpp" , "hpp" , "inc" ] . contains ( & ext. as_str ( ) ) {
227+ return completion:: completion ( params. text_document_position , params. context ) . await ;
228+ }
229+ Ok ( None )
230+ }
211231}
212232
213233impl Backend {
0 commit comments