diff options
| author | DanielGavin <danielgavin5@hotmail.com> | 2023-07-01 11:16:57 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-07-01 11:16:57 +0200 |
| commit | 40f992f4f051e343331f44aa4c791e6f6abc8426 (patch) | |
| tree | d42776802f8c7e1ebfc0a4170c04fd86573f9fc1 /src/server | |
| parent | ebf41d5450e8ec0001d8dd1c196565255df043f2 (diff) | |
| parent | 0da804aac2e7b76d2cf75436fc5a1b005ea27b75 (diff) | |
Merge pull request #215 from ryuukk/details
Format labelDetails for procs that returns and variables/constants
Diffstat (limited to 'src/server')
| -rw-r--r-- | src/server/completion.odin | 47 |
1 files changed, 39 insertions, 8 deletions
diff --git a/src/server/completion.odin b/src/server/completion.odin index 572026f..10a1583 100644 --- a/src/server/completion.odin +++ b/src/server/completion.odin @@ -1817,18 +1817,49 @@ 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 { - if item.kind == .Function && true { - proc_index := strings.index(item.detail, "proc") - - item.labelDetails = CompletionItemLabelDetails { - detail = item.detail[proc_index + 4:len(item.detail)], - } - } + // log.errorf("item:%v: %v:%v", item.kind, item.label, item.detail) + #partial switch item.kind { + case .Function: + 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 = "" + } + case .Variable, .Constant, .Field: + type_index := strings.index(item.detail, ":") + item.labelDetails = CompletionItemLabelDetails { + detail = "", + description = item.detail[type_index+1:] + } + item.detail = item.label + case .Struct, .Enum, .Class: + type_index := strings.index(item.detail, ":") + item.labelDetails = CompletionItemLabelDetails { + detail = "", + description = item.detail[type_index+1:] + } + item.detail = item.label + case .Keyword: + item.detail = "keyword" + } } } - bitset_operators: map[string]bool = { "|" = true, "&" = true, |