1
- using Microsoft . Extensions . Logging ;
1
+ using Microsoft . Extensions . Configuration ;
2
+ using Microsoft . Extensions . Logging ;
2
3
using OmniSharp . Extensions . LanguageServer . Protocol . Client . Capabilities ;
3
4
using OmniSharp . Extensions . LanguageServer . Protocol . Document ;
4
5
using OmniSharp . Extensions . LanguageServer . Protocol . Models ;
@@ -37,10 +38,15 @@ public override Task<CompletionItem> Handle(CompletionItem request, Cancellation
37
38
38
39
public override async Task < CompletionList > Handle ( CompletionParams request , CancellationToken cancellationToken )
39
40
{
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 ) ;
41
45
}
42
46
43
- protected override CompletionRegistrationOptions CreateRegistrationOptions ( CompletionCapability capability , ClientCapabilities clientCapabilities )
47
+ protected override CompletionRegistrationOptions CreateRegistrationOptions (
48
+ CompletionCapability capability ,
49
+ ClientCapabilities clientCapabilities )
44
50
=> new CompletionRegistrationOptions ( )
45
51
{
46
52
DocumentSelector = _documentSelector ,
@@ -49,13 +55,15 @@ protected override CompletionRegistrationOptions CreateRegistrationOptions(Compl
49
55
AllCommitCharacters = new Container < string > ( new [ ] { "\n " } )
50
56
} ;
51
57
52
- public CompletionList GenerateCompletions ( CompletionParams request , CancellationToken cancellationToken )
58
+ public CompletionList GenerateCompletions (
59
+ CompletionParams request ,
60
+ ServerOptions options )
53
61
{
54
62
var uri = request . TextDocument . Uri ;
55
63
56
64
var completions = new List < CompletionItem > ( ) ;
57
65
var keywords = new HashSet < string > ( ) ;
58
-
66
+
59
67
var dm = ShaderlabDataManager . Instance ;
60
68
61
69
// Add functions into auto completion list
@@ -199,17 +207,21 @@ public CompletionList GenerateCompletions(CompletionParams request, Cancellation
199
207
200
208
// Add words in current file
201
209
//
202
- foreach ( var word in _workspace . BufferService . Tokens ( uri ) )
210
+ _logger . LogWarning ( "ooo: " + options . CompletionWord ) ;
211
+ if ( options . CompletionWord )
203
212
{
204
- if ( ! keywords . Contains ( word ) && word != current )
213
+ foreach ( var word in _workspace . BufferService . Tokens ( uri ) )
205
214
{
206
- completions . Add ( new CompletionItem
215
+ if ( ! keywords . Contains ( word ) && word != current )
207
216
{
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
+ }
213
225
}
214
226
}
215
227
0 commit comments