diff options
| author | cornishon <zadroznyadam@pm.me> | 2025-02-02 13:15:30 +0100 |
|---|---|---|
| committer | cornishon <zadroznyadam@pm.me> | 2025-02-02 13:15:30 +0100 |
| commit | f6f8dbdd741d5d9ea4e9db1beee35f6451a23bba (patch) | |
| tree | eb8594ac19f973c6c3d5a8cf48375feb3e1a0d69 /src | |
| parent | 464f1a9d886e6f79de3cb2275854c5769659daa5 (diff) | |
Extra builtin procedures for maps
Diffstat (limited to 'src')
| -rw-r--r-- | src/server/completion.odin | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/server/completion.odin b/src/server/completion.odin index 47ab82c..8d521d6 100644 --- a/src/server/completion.odin +++ b/src/server/completion.odin @@ -1780,6 +1780,59 @@ append_magic_map_completion :: proc( append(items, item) } + + prefix := "&" + suffix := "" + if symbol.pointers > 0 { + prefix = "" + suffix = common.repeat("^", symbol.pointers - 1, context.temp_allocator) + } + ptr_symbol_str := fmt.tprint(prefix, symbol_str, suffix, sep = "") + + map_builtins_no_arg := []string { + "clear", + "shrink", + } + + for name in map_builtins_no_arg { + item := CompletionItem { + label = name, + kind = .Function, + detail = name, + textEdit = TextEdit { + newText = fmt.tprintf("%s(%v)", name, ptr_symbol_str), + range = {start = range.end, end = range.end}, + }, + additionalTextEdits = additionalTextEdits, + } + + append(items, item) + } + + map_builtins_with_args := []string { + "delete_key", + "reserve", + "map_insert", + "map_upsert", + "map_entry", + } + + for name in map_builtins_with_args { + item := CompletionItem { + label = name, + kind = .Snippet, + detail = name, + additionalTextEdits = additionalTextEdits, + textEdit = TextEdit { + newText = fmt.tprintf("%s(%v, $0)", name, ptr_symbol_str), + range = {start = range.end, end = range.end}, + }, + insertTextFormat = .Snippet, + InsertTextMode = .adjustIndentation, + } + + append(items, item) + } } get_expression_string_from_position_context :: proc(position_context: ^DocumentPositionContext) -> string { src := position_context.file.src |