@@ -82,7 +82,11 @@ func Completion(ctx context.Context, params *protocol.CompletionParams, doc docu
82
82
return & protocol.CompletionList {Items : dependencies }, nil
83
83
}
84
84
85
- items := namedDependencyCompletionItems (file , path , "configs" , "configs" , params , protocol .UInteger (len (wordPrefix )))
85
+ items := volumeDependencyCompletionItems (file , path , params , protocol .UInteger (len (wordPrefix )))
86
+ if len (items ) > 0 {
87
+ return & protocol.CompletionList {Items : items }, nil
88
+ }
89
+ items = namedDependencyCompletionItems (file , path , "configs" , "configs" , params , protocol .UInteger (len (wordPrefix )))
86
90
if len (items ) == 0 {
87
91
items = namedDependencyCompletionItems (file , path , "secrets" , "secrets" , params , protocol .UInteger (len (wordPrefix )))
88
92
}
@@ -201,7 +205,6 @@ func dependencyCompletionItems(file *ast.File, path []*ast.MappingValueNode, par
201
205
dependency := map [string ]string {
202
206
"depends_on" : "services" ,
203
207
"networks" : "networks" ,
204
- "volumes" : "volumes" ,
205
208
}
206
209
for serviceAttribute , dependencyType := range dependency {
207
210
items := namedDependencyCompletionItems (file , path , serviceAttribute , dependencyType , params , prefixLength )
@@ -212,6 +215,19 @@ func dependencyCompletionItems(file *ast.File, path []*ast.MappingValueNode, par
212
215
return nil
213
216
}
214
217
218
+ func volumeDependencyCompletionItems (file * ast.File , path []* ast.MappingValueNode , params * protocol.CompletionParams , prefixLength protocol.UInteger ) []protocol.CompletionItem {
219
+ items := namedDependencyCompletionItems (file , path , "volumes" , "volumes" , params , prefixLength )
220
+ for i := range items {
221
+ edit := items [i ].TextEdit .(protocol.TextEdit )
222
+ items [i ].TextEdit = protocol.TextEdit {
223
+ NewText : fmt .Sprintf ("%v:${1:/container/path}" , edit .NewText ),
224
+ Range : edit .Range ,
225
+ }
226
+ items [i ].InsertTextFormat = types .CreateInsertTextFormatPointer (protocol .InsertTextFormatSnippet )
227
+ }
228
+ return items
229
+ }
230
+
215
231
func namedDependencyCompletionItems (file * ast.File , path []* ast.MappingValueNode , serviceAttribute , dependencyType string , params * protocol.CompletionParams , prefixLength protocol.UInteger ) []protocol.CompletionItem {
216
232
if len (path ) == 3 && path [2 ].Key .GetToken ().Value == serviceAttribute {
217
233
items := []protocol.CompletionItem {}
0 commit comments