From 6e6528da0b817366393f534cda4a59a19afb076b Mon Sep 17 00:00:00 2001 From: Hamza Ali Date: Tue, 18 Jun 2024 13:52:29 +0500 Subject: add additional completion snippets for dynamic arrays --- src/server/completion.odin | 50 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'src/server/completion.odin') diff --git a/src/server/completion.odin b/src/server/completion.odin index e404b78..91cc790 100644 --- a/src/server/completion.odin +++ b/src/server/completion.odin @@ -1947,6 +1947,56 @@ append_magic_dynamic_array_completion :: proc( append(items, item) } + // This proc is shared between slices and dynamic arrays. + if _, ok := symbol.value.(SymbolDynamicArrayValue); !ok { + return + } + + //pop + { + text := fmt.tprintf("pop(&%v)", symbol_str) + + item := CompletionItem { + label = "pop", + kind = .Function, + detail = "pop", + textEdit = TextEdit { + newText = text, + range = {start = range.end, end = range.end}, + }, + additionalTextEdits = additionalTextEdits, + } + + append(items, item) + } + + dynamic_array_builtins := []string { + "append", + "unordered_remove", + "ordered_remove", + "resize", + "reserve", + "shrink", + "inject_at", + "assign_at", + } + + for name in dynamic_array_builtins { + item := CompletionItem { + label = name, + kind = .Snippet, + detail = name, + additionalTextEdits = additionalTextEdits, + textEdit = TextEdit { + newText = fmt.tprintf("%s(&%v, $0)", name, symbol_str), + range = {start = range.end, end = range.end}, + }, + insertTextFormat = .Snippet, + InsertTextMode = .adjustIndentation, + } + + append(items, item) + } } append_magic_union_completion :: proc( -- cgit v1.2.3