vscodeプラグインファーストフードチュートリアル(6) - 初期化がLSP契約パラメータ
LSPのコード補完を学んだ後、私たちは、LSPシステムを実行することができます構築しようとすることができます。
これに先立ち、詳細のいくつかと、我々はそれを強化します。
第4節では、LSPのハンドシェイクの初期化を導入しています。
私たちは、クライアントの能力として、接続onInitialize機能でクライアントの初期化パラメータを受け取ることができます。
connection.onInitialize((params: InitializeParams) => {
let capabilities = params.capabilities;
return {
capabilities: {
textDocumentSync: documents.syncKind,
// Tell the client that the server supports code completion
completionProvider: {
resolveProvider: true
}
}
};
})
さんが含まれているコンテンツのLSPの初期化パラメータを使用してマップを見てみましょう:
のは、これらの定義を見てみましょう:
interface InitializeParams {
/**
* The process Id of the parent process that started
* the server. Is null if the process has not been started by another process.
* If the parent process is not alive then the server should exit (see exit notification) its process.
*/
processId: number | null;
/**
* The rootPath of the workspace. Is null
* if no folder is open.
*
* @deprecated in favour of rootUri.
*/
rootPath?: string | null;
/**
* The rootUri of the workspace. Is null if no
* folder is open. If both `rootPath` and `rootUri` are set
* `rootUri` wins.
*/
rootUri: DocumentUri | null;
/**
* User provided initialization options.
*/
initializationOptions?: any;
/**
* The capabilities provided by the client (editor or tool)
*/
capabilities: ClientCapabilities;
/**
* The initial trace setting. If omitted trace is disabled ('off').
*/
trace?: 'off' | 'messages' | 'verbose';
/**
* The workspace folders configured in the client when the server starts.
* This property is only available if the client supports workspace folders.
* It can be `null` if the client supports workspace folders but none are
* configured.
*
* Since 3.6.0
*/
workspaceFolders?: WorkspaceFolder[] | null;
}
以下に示すように私たちは、上記のクラス情報を分割しました:
情報の3つのタイプがあります。
- 一つは、経路情報及びプロセス関連情報として、動作環境情報に関連しています。
- 第二は、ケイパビリティ情報です。
- 第三に、いくつかの補助ユーザ定義の設定などの情報、およびトレース情報を。
パス情報は、あなたが得ることができる場合、プラグインvscodeがディレクトリを開いている実行されています。
私が開いている場合、ディレクトリは/ユーザ/ ziyingliuziying /作業/ gitlab / cafmode /サーバー、 そして結果が返されROOTPATH:/ユーザー/ ziyingliuziying /作業/ gitlab / cafmode /サーバー。その結果rootUriを返します。file:///ユーザ/ ziyingliuziying /作業/ gitlab / cafmode /サーバー。
workspaceFoldersはWorkspaceFolderのアレイから構成されています。各オブジェクトは、名前から構成され、URIそのWorkspaceFolderです。上記の例では、例えば:サーバーの名前は、URIはファイルです:///ユーザ/ ziyingliuziying /作業 / gitlab / cafmode /サーバー