smarter completion (via context)
This commit is contained in:
@@ -11,8 +11,8 @@ interface FC {
|
|||||||
|
|
||||||
interface TopEntry {
|
interface TopEntry {
|
||||||
fc: FC;
|
fc: FC;
|
||||||
name: String;
|
name: string;
|
||||||
type: String;
|
type: string;
|
||||||
}
|
}
|
||||||
interface TopData {
|
interface TopData {
|
||||||
context: TopEntry[];
|
context: TopEntry[];
|
||||||
@@ -182,7 +182,28 @@ export function activate(context: vscode.ExtensionContext) {
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
context.subscriptions.push(
|
||||||
|
vscode.languages.registerCompletionItemProvider(
|
||||||
|
{ language: "newt" },
|
||||||
|
{
|
||||||
|
provideCompletionItems(document, position, token, context) {
|
||||||
|
if (!topData) return [];
|
||||||
|
const wordRange = document.getWordRangeAtPosition(position);
|
||||||
|
const prefix = wordRange ? document.getText(wordRange) : "";
|
||||||
|
const items: vscode.CompletionItem[] = [];
|
||||||
|
for (const entry of topData.context) {
|
||||||
|
if (entry.name.startsWith(prefix)) {
|
||||||
|
const item = new vscode.CompletionItem(entry.name, vscode.CompletionItemKind.Function);
|
||||||
|
item.detail = entry.type;
|
||||||
|
items.push(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
...'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_'.split('')
|
||||||
|
)
|
||||||
|
);
|
||||||
context.subscriptions.push(
|
context.subscriptions.push(
|
||||||
vscode.languages.registerHoverProvider(
|
vscode.languages.registerHoverProvider(
|
||||||
{ language: "newt" },
|
{ language: "newt" },
|
||||||
|
|||||||
Reference in New Issue
Block a user