diff options
| author | ryuukk <ryuukk.dev@gmail.com> | 2023-06-29 18:50:02 +0200 |
|---|---|---|
| committer | ryuukk <ryuukk.dev@gmail.com> | 2023-06-29 18:50:02 +0200 |
| commit | 9ee1077ffb2371674951bd2ed3bfe654c16e4709 (patch) | |
| tree | c71d09138b7cdbc6a58645635f4b5dc9aa4e91b6 /src/server | |
| parent | f2427a91ba14cb1fc730d42fea8d309a13608325 (diff) | |
Format labelDetails for procs that returns and variables/constants
Diffstat (limited to 'src/server')
| -rw-r--r-- | src/server/completion.odin | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/src/server/completion.odin b/src/server/completion.odin index 77cc399..97c2d9b 100644 --- a/src/server/completion.odin +++ b/src/server/completion.odin @@ -1768,14 +1768,36 @@ append_magic_union_completion :: proc( //Temporary hack to support labeldetails format_to_label_details :: proc(list: ^CompletionList) { + // detail = left + // description = right for item in &list.items { + // log.errorf("item:%v: %v:%v", item.kind, item.label, item.detail) if item.kind == .Function && true { - proc_index := strings.index(item.detail, "proc") - - item.labelDetails = CompletionItemLabelDetails { - detail = item.detail[proc_index + 4:len(item.detail)], - } - } + proc_index := strings.index(item.detail, ": proc") + // check if the function return somrthing + proc_return_index := strings.index(item.detail, "->") + if proc_return_index > 0 { + proc_end_index := strings.index(item.detail[0:proc_return_index], ")") + item.labelDetails = CompletionItemLabelDetails { + detail = item.detail[proc_index + 6: proc_return_index], + description = item.detail[proc_return_index:] + } + item.detail = item.label + } else { + item.labelDetails = CompletionItemLabelDetails { + detail = item.detail[proc_index + 6:len(item.detail)], + description = "" + } + item.detail = "" + } + } else if item.kind == .Variable || item.kind == .Constant { + type_index := strings.index(item.detail, ":") + item.labelDetails = CompletionItemLabelDetails { + detail = "", + description = item.detail[type_index+1:] + } + item.detail = "" + } } } |