Skip to content

Commit

Permalink
🚧 #1 CompletionItemProvider
Browse files Browse the repository at this point in the history
CompletionItemProvider
  • Loading branch information
kalifun committed Oct 14, 2022
1 parent 3117a51 commit 40f67ec
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/api/completion/completion.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

import vscode = require('vscode');

class Proto3CompletionItemProvider implements vscode.CompletionItemProvider {
provideCompletionItems(
document: vscode.TextDocument,
position: vscode.Position,
token: vscode.CancellationToken,
context: vscode.CompletionContext
): vscode.ProviderResult<vscode.CompletionItem[] | vscode.CompletionList<vscode.CompletionItem>> {
throw new Error('Method not implemented.');
}
resolveCompletionItem?(item: vscode.CompletionItem, token: vscode.CancellationToken): vscode.ProviderResult<vscode.CompletionItem> {
throw new Error('Method not implemented.');
}
}


export { Proto3CompletionItemProvider };
6 changes: 6 additions & 0 deletions src/conf/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import vscode = require('vscode');

export const Proto3: vscode.DocumentSelector = {
scheme: "file",
language: "proto3"
};
5 changes: 5 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// The module 'vscode' contains the VS Code extensibility API
// Import the module and reference it with the alias vscode in your code below
import * as vscode from 'vscode';
import { Proto3CompletionItemProvider } from './api/completion/completion';
import { Proto3 } from './conf/config';



Expand All @@ -12,6 +14,9 @@ export function activate(context: vscode.ExtensionContext) {
// This line of code will only be executed once when your extension is activated
console.log('Congratulations, your extension "demo" is now active!');

// 注册一个自动补全
context.subscriptions.push(vscode.languages.registerCompletionItemProvider(Proto3, new Proto3CompletionItemProvider(), '.', '\"'));

// The command has been defined in the package.json file
// Now provide the implementation of the command with registerCommand
// The commandId parameter must match the command field in package.json
Expand Down

0 comments on commit 40f67ec

Please sign in to comment.