Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Use more icons in autocomplete box #1961

Merged
merged 1 commit into from
Oct 12, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions src/goSuggest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,20 @@ import { getTextEditForAddImport } from './goImport';
import { getImportablePackages } from './goPackages';
import { isModSupported } from './goModules';

function vscodeKindFromGoCodeClass(kind: string): vscode.CompletionItemKind {
function vscodeKindFromGoCodeClass(kind: string, type: string): vscode.CompletionItemKind {
switch (kind) {
case 'const':
return vscode.CompletionItemKind.Constant;
case 'package':
return vscode.CompletionItemKind.Module;
case 'type':
return vscode.CompletionItemKind.Class;
switch (type) {
case 'struct':
return vscode.CompletionItemKind.Class;
case 'interface':
return vscode.CompletionItemKind.Interface;
}
return vscode.CompletionItemKind.Struct;
case 'func':
return vscode.CompletionItemKind.Function;
case 'var':
Expand Down Expand Up @@ -75,7 +81,7 @@ export class GoCompletionItemProvider implements vscode.CompletionItemProvider {
let memberType = nextLine.match(exportedMemberRegex);
let suggestionItem: vscode.CompletionItem;
if (memberType && memberType.length === 4) {
suggestionItem = new vscode.CompletionItem(memberType[3], vscodeKindFromGoCodeClass(memberType[1]));
suggestionItem = new vscode.CompletionItem(memberType[3], vscodeKindFromGoCodeClass(memberType[1], ''));
}
return resolve(suggestionItem ? [suggestionItem] : []);
}
Expand Down Expand Up @@ -218,7 +224,7 @@ export class GoCompletionItemProvider implements vscode.CompletionItemProvider {
for (let suggest of results[1]) {
if (inString && suggest.class !== 'import') continue;
let item = new vscode.CompletionItem(suggest.name);
item.kind = vscodeKindFromGoCodeClass(suggest.class);
item.kind = vscodeKindFromGoCodeClass(suggest.class, suggest.type);
item.detail = suggest.type;
if (inString && suggest.class === 'import') {
item.textEdit = new vscode.TextEdit(
Expand Down