1- using Microsoft . Extensions . Logging ;
1+ using Microsoft . Extensions . Configuration ;
2+ using Microsoft . Extensions . Logging ;
23using OmniSharp . Extensions . LanguageServer . Protocol . Client . Capabilities ;
34using OmniSharp . Extensions . LanguageServer . Protocol . Document ;
45using OmniSharp . Extensions . LanguageServer . Protocol . Models ;
@@ -37,10 +38,15 @@ public override Task<CompletionItem> Handle(CompletionItem request, Cancellation
3738
3839 public override async Task < CompletionList > Handle ( CompletionParams request , CancellationToken cancellationToken )
3940 {
40- return GenerateCompletions ( request , cancellationToken ) ;
41+ var conf = await _configuration . GetScopedConfiguration ( request . TextDocument . Uri , cancellationToken ) ;
42+ var options = new ServerOptions ( ) ;
43+ conf . GetSection ( "ShaderLab" ) . Bind ( options ) ;
44+ return GenerateCompletions ( request , options ) ;
4145 }
4246
43- protected override CompletionRegistrationOptions CreateRegistrationOptions ( CompletionCapability capability , ClientCapabilities clientCapabilities )
47+ protected override CompletionRegistrationOptions CreateRegistrationOptions (
48+ CompletionCapability capability ,
49+ ClientCapabilities clientCapabilities )
4450 => new CompletionRegistrationOptions ( )
4551 {
4652 DocumentSelector = _documentSelector ,
@@ -49,13 +55,15 @@ protected override CompletionRegistrationOptions CreateRegistrationOptions(Compl
4955 AllCommitCharacters = new Container < string > ( new [ ] { "\n " } )
5056 } ;
5157
52- public CompletionList GenerateCompletions ( CompletionParams request , CancellationToken cancellationToken )
58+ public CompletionList GenerateCompletions (
59+ CompletionParams request ,
60+ ServerOptions options )
5361 {
5462 var uri = request . TextDocument . Uri ;
5563
5664 var completions = new List < CompletionItem > ( ) ;
5765 var keywords = new HashSet < string > ( ) ;
58-
66+
5967 var dm = ShaderlabDataManager . Instance ;
6068
6169 // Add functions into auto completion list
@@ -199,17 +207,21 @@ public CompletionList GenerateCompletions(CompletionParams request, Cancellation
199207
200208 // Add words in current file
201209 //
202- foreach ( var word in _workspace . BufferService . Tokens ( uri ) )
210+ _logger . LogWarning ( "ooo: " + options . CompletionWord ) ;
211+ if ( options . CompletionWord )
203212 {
204- if ( ! keywords . Contains ( word ) && word != current )
213+ foreach ( var word in _workspace . BufferService . Tokens ( uri ) )
205214 {
206- completions . Add ( new CompletionItem
215+ if ( ! keywords . Contains ( word ) && word != current )
207216 {
208- Kind = CompletionItemKind . Text ,
209- Label = word ,
210- InsertText = word ,
211- Documentation = new MarkupContent { Kind = MarkupKind . Markdown , Value = string . Empty } ,
212- } ) ;
217+ completions . Add ( new CompletionItem
218+ {
219+ Kind = CompletionItemKind . Text ,
220+ Label = word ,
221+ InsertText = word ,
222+ Documentation = new MarkupContent { Kind = MarkupKind . Markdown , Value = string . Empty } ,
223+ } ) ;
224+ }
213225 }
214226 }
215227
0 commit comments