aboutsummaryrefslogtreecommitdiff
path: root/src/server/completion.odin
diff options
context:
space:
mode:
authorHamza Ali <me@hamzantal.pw>2024-06-18 13:52:29 +0500
committerHamza Ali <me@hamzantal.pw>2024-06-18 13:53:16 +0500
commit6e6528da0b817366393f534cda4a59a19afb076b (patch)
treef5b27d6cbd38f12eaedb322a5df65cd8ea941c58 /src/server/completion.odin
parente37b1946f3c322699507ff6f0414f7b29fe58946 (diff)
add additional completion snippets for dynamic arrays
Diffstat (limited to 'src/server/completion.odin')
-rw-r--r--src/server/completion.odin50
1 files changed, 50 insertions, 0 deletions
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(