本文整理匯總了TypeScript中vscode-languageclient.LanguageClient.onReady方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript LanguageClient.onReady方法的具體用法?TypeScript LanguageClient.onReady怎麽用?TypeScript LanguageClient.onReady使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類vscode-languageclient.LanguageClient
的用法示例。
在下文中一共展示了LanguageClient.onReady方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: activate
export async function activate(_: vscode.ExtensionContext) {
let serverOptions = {
command: "pyre",
args: ["persistent"]
};
let clientOptions: LanguageClientOptions = {
documentSelector: [{scheme: 'file', language: 'python'}],
synchronize: {
// Notify the server about file changes to '.clientrc files contain in the workspace
fileEvents: vscode.workspace.createFileSystemWatcher('**/.clientrc'),
}
};
const languageClient = new LanguageClient(
'pyre',
'Pyre Language Client',
serverOptions,
clientOptions,
)
languageClient.registerProposedFeatures();
languageClient.onReady().then(() => {
Configuration.initialize();
});
languageClient.start();
}
示例2: activateLanguageServer
export async function activateLanguageServer(context: vscode.ExtensionContext) {
const r = RLanguage.language;
// The server is implemented in C#
const commandOptions = { stdio: "pipe" };
const serverModule = context.extensionPath + "/server/Microsoft.R.LanguageServer.dll";
// If the extension is launched in debug mode then the debug server options are used
// Otherwise the run options are used
const serverOptions: languageClient.ServerOptions = {
debug: { command: "dotnet", args: [serverModule, "--debug"], options: commandOptions },
run: { command: "dotnet", args: [serverModule], options: commandOptions },
};
// Options to control the language client
const clientOptions: languageClient.LanguageClientOptions = {
// Register the server for R documents
documentSelector: [r],
synchronize: {
configurationSection: r,
},
};
// Create the language client and start the client.
client = new languageClient.LanguageClient(r, "R Tools", serverOptions, clientOptions);
context.subscriptions.push(client.start());
await client.onReady();
rEngine = new REngine(client);
const resultsView = new ResultsView();
context.subscriptions.push(vscode.workspace.registerTextDocumentContentProvider("r", resultsView));
commands = new Commands(rEngine, resultsView);
context.subscriptions.push(...commands.activateCommandsProvider());
}
示例3: run
function run(serverOptions: ServerOptions, isOldServer: boolean) {
const clientOptions: LanguageClientOptions = {
documentSelector: [
{ scheme: 'file', pattern: '**/*.sc' },
{ scheme: 'untitled', pattern: '**/*.sc' },
{ scheme: 'file', pattern: '**/*.scala' },
{ scheme: 'untitled', pattern: '**/*.scala' }
],
synchronize: {
configurationSection: 'dotty'
},
outputChannel: outputChannel,
revealOutputChannelOn: RevealOutputChannelOn.Never
}
client = new LanguageClient("dotty", "Dotty", serverOptions, clientOptions)
if (isOldServer)
enableOldServerWorkaround(client)
client.onReady().then(() => {
client.onNotification("worksheet/publishOutput", (params) => {
worksheet.handleMessage(params)
})
})
vscode.commands.registerCommand(worksheet.worksheetEvaluateKey, () => {
worksheet.evaluateWorksheetCommand()
})
// Push the disposable to the context's subscriptions so that the
// client can be deactivated on extension deactivation
extensionContext.subscriptions.push(client.start());
}
示例4: activate
export function activate(context: ExtensionContext) {
let packageInfo = getPackageInfo(context);
let telemetryReporter: TelemetryReporter = packageInfo && new TelemetryReporter(packageInfo.name, packageInfo.version, packageInfo.aiKey);
context.subscriptions.push(telemetryReporter);
// The server is implemented in node
let serverModule = context.asAbsolutePath(path.join('server', 'out', 'jsonServerMain.js'));
// The debug options for the server
let debugOptions = { execArgv: ['--nolazy', '--debug=6004'] };
// If the extension is launch in debug mode the debug server options are use
// Otherwise the run options are used
let serverOptions: ServerOptions = {
run: { module: serverModule, transport: TransportKind.ipc },
debug: { module: serverModule, transport: TransportKind.ipc, options: debugOptions }
};
// Options to control the language client
let clientOptions: LanguageClientOptions = {
// Register the server for json documents
documentSelector: ['json'],
synchronize: {
// Synchronize the setting section 'json' to the server
configurationSection: ['json', 'http.proxy', 'http.proxyStrictSSL'],
fileEvents: workspace.createFileSystemWatcher('**/*.json')
}
};
// Create the language client and start the client.
let client = new LanguageClient('json', localize('jsonserver.name', 'JSON Language Server'), serverOptions, clientOptions);
let disposable = client.start();
client.onReady().then(() => {
client.onTelemetry(e => {
if (telemetryReporter) {
telemetryReporter.sendTelemetryEvent(e.key, e.data);
}
});
// handle content request
client.onRequest(VSCodeContentRequest.type, (uriPath: string) => {
let uri = Uri.parse(uriPath);
return workspace.openTextDocument(uri).then(doc => {
return doc.getText();
}, error => {
return Promise.reject(error);
});
});
client.sendNotification(SchemaAssociationNotification.type, getSchemaAssociation(context));
});
// Push the disposable to the context's subscriptions so that the
// client can be deactivated on extension deactivation
context.subscriptions.push(disposable);
languages.setLanguageConfiguration('json', {
wordPattern: /("(?:[^\\\"]*(?:\\.)?)*"?)|[^\s{}\[\],:]+/
});
}
示例5: activate
export function activate(context: ExtensionContext) {
// build path to server module
let serverModule = context.asAbsolutePath(path.join('server', 'main.js'));
// server debug options
let debugOptions = {
execArgv: [
"--nolazy",
"--inspect=6004"
]
};
// create server options
let serverOptions: ServerOptions = {
run: {
module: serverModule,
transport: TransportKind.ipc
},
debug: {
module: serverModule,
transport: TransportKind.ipc,
options: debugOptions
}
}
// create client options
let clientOptions: LanguageClientOptions = {
documentSelector: [
{ scheme: 'file', language: 'yaml' },
{ scheme: 'file', language: 'yml' },
{ scheme: 'file', language: 'json' }
],
synchronize: {
configurationSection: "swaggitor",
fileEvents: workspace.createFileSystemWatcher('**/.clientrc')
}
};
let languageClient = new LanguageClient('swaggitor', 'Swaggitor Server', serverOptions, clientOptions);
languageClient.onReady().then(() => {
// add a request to handle displaying a status bar message after validation
languageClient.onRequest("validated", (params: any): void => {
if (params != null) {
window.setStatusBarMessage(params.message, 2000);
}
else {
window.setStatusBarMessage('Swagger definition is valid!', 2000);
}
});
});
let disposable: Disposable = languageClient.start();
context.subscriptions.push(disposable);
}
示例6: getMetrics
public getMetrics(document: TextDocument): Thenable<IMetricsModel[]> {
const requestData: RequestData = {
uri: document.uri.toString(),
configuration: this.appConfig.getCodeMetricsSettings(document.uri)
};
return this.client.onReady().then(() =>
this.client.sendRequest(MetricsRequestType, requestData).then(metrics =>
metrics.map(m => {
return this.convert(m);
})
)
);
}
示例7: startLanguageClient
function startLanguageClient(pipeName: string) {
try
{
let connectFunc = () => {
return new Promise<StreamInfo>(
(resolve, reject) => {
var socket = net.connect("\\\\.\\pipe\\" + pipeName);
socket.on(
'connect',
function() {
console.log("Pipe connected!");
resolve({writer: socket, reader: socket})
});
});
};
let clientOptions: LanguageClientOptions = {
documentSelector: [PowerShellLanguageId],
synchronize: {
configurationSection: PowerShellLanguageId,
//fileEvents: vscode.workspace.createFileSystemWatcher('**/.eslintrc')
}
}
languageServerClient =
new LanguageClient(
'PowerShell Editor Services',
connectFunc,
clientOptions);
languageServerClient.onReady().then(
() => registerFeatures(),
(reason) => vscode.window.showErrorMessage("Could not start language service: " + reason));
languageServerClient.start();
}
catch (e)
{
vscode.window.showErrorMessage(
"The language service could not be started: " + e);
}
}
示例8: activate
export async function activate(context: ExtensionContext) {
const serverModule = require.resolve('./lib/server');
const debugOptions = { execArgv: ['--inspect'] }; // Turn on debugging messages in output
const serverOptions: ServerOptions = {
run: { module: serverModule, transport: TransportKind.ipc },
debug: { module: serverModule, transport: TransportKind.ipc, options: debugOptions, runtime: 'node' }
};
const clientOptions: LanguageClientOptions = {
documentSelector: [{ language: 'stylable' }, { language: 'typescript' }, { language: 'javascript' }],
diagnosticCollectionName: 'stylable'
};
const client = new LanguageClient('stylable', serverOptions, clientOptions);
client.trace = Trace.Verbose; // Elevate debugging message info in output
context.subscriptions.push(client.start());
await client.onReady();
// const files = await workspace.findFiles('**/*.st.css');
// await Promise.all(files.map((file: any) => workspace.openTextDocument(file.fsPath)));
return client;
}
示例9: activate
export function activate(context: ExtensionContext) {
let toDispose = context.subscriptions;
let packageInfo = getPackageInfo(context);
telemetryReporter = packageInfo && new TelemetryReporter(packageInfo.name, packageInfo.version, packageInfo.aiKey);
// The server is implemented in node
let serverModule = context.asAbsolutePath(path.join('server', 'out', 'htmlServerMain.js'));
// The debug options for the server
let debugOptions = { execArgv: ['--nolazy', '--inspect=6045'] };
// If the extension is launch in debug mode the debug server options are use
// Otherwise the run options are used
let serverOptions: ServerOptions = {
run: { module: serverModule, transport: TransportKind.ipc },
debug: { module: serverModule, transport: TransportKind.ipc, options: debugOptions }
};
let documentSelector = ['html', 'handlebars', 'razor'];
let embeddedLanguages = { css: true, javascript: true };
// Options to control the language client
let clientOptions: LanguageClientOptions = {
documentSelector,
synchronize: {
configurationSection: ['html', 'css', 'javascript'], // the settings to synchronize
},
initializationOptions: {
embeddedLanguages
}
};
// Create the language client and start the client.
let client = new LanguageClient('html', localize('htmlserver.name', 'HTML Language Server'), serverOptions, clientOptions);
client.registerProposedFeatures();
let disposable = client.start();
toDispose.push(disposable);
client.onReady().then(() => {
disposable = languages.registerColorProvider(documentSelector, {
provideDocumentColors(document: TextDocument): Thenable<ColorInformation[]> {
let params: DocumentColorParams = {
textDocument: client.code2ProtocolConverter.asTextDocumentIdentifier(document)
};
return client.sendRequest(DocumentColorRequest.type, params).then(symbols => {
return symbols.map(symbol => {
let range = client.protocol2CodeConverter.asRange(symbol.range);
let color = new Color(symbol.color.red, symbol.color.green, symbol.color.blue, symbol.color.alpha);
return new ColorInformation(range, color);
});
});
},
provideColorPresentations(color, context): Thenable<ColorPresentation[]> {
let params: ColorPresentationParams = {
textDocument: client.code2ProtocolConverter.asTextDocumentIdentifier(context.document),
color,
range: client.code2ProtocolConverter.asRange(context.range)
};
return client.sendRequest(ColorPresentationRequest.type, params).then(presentations => {
return presentations.map(p => {
let presentation = new ColorPresentation(p.label);
presentation.textEdit = p.textEdit && client.protocol2CodeConverter.asTextEdit(p.textEdit);
presentation.additionalTextEdits = p.additionalTextEdits && client.protocol2CodeConverter.asTextEdits(p.additionalTextEdits);
return presentation;
});
});
}
});
toDispose.push(disposable);
let tagRequestor = (document: TextDocument, position: Position) => {
let param = client.code2ProtocolConverter.asTextDocumentPositionParams(document, position);
return client.sendRequest(TagCloseRequest.type, param);
};
disposable = activateTagClosing(tagRequestor, { html: true, handlebars: true, razor: true }, 'html.autoClosingTags');
toDispose.push(disposable);
disposable = client.onTelemetry(e => {
if (telemetryReporter) {
telemetryReporter.sendTelemetryEvent(e.key, e.data);
}
});
toDispose.push(disposable);
});
languages.setLanguageConfiguration('html', {
indentationRules: {
increaseIndentPattern: /<(?!\?|(?:area|base|br|col|frame|hr|html|img|input|link|meta|param)\b|[^>]*\/>)([-_\.A-Za-z0-9]+)(?=\s|>)\b[^>]*>(?!.*<\/\1>)|<!--(?!.*-->)|\{[^}"']*$/,
decreaseIndentPattern: /^\s*(<\/(?!html)[-_\.A-Za-z0-9]+\b[^>]*>|-->|\})/
},
wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\@\$\^\&\*\(\)\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\s]+)/g,
onEnterRules: [
{
beforeText: new RegExp(`<(?!(?:${EMPTY_ELEMENTS.join('|')}))([_:\\w][_:\\w-.\\d]*)([^/>]*(?!/)>)[^<]*$`, 'i'),
afterText: /^<\/([_:\w][_:\w-.\d]*)\s*>/i,
action: { indentAction: IndentAction.IndentOutdent }
},
{
beforeText: new RegExp(`<(?!(?:${EMPTY_ELEMENTS.join('|')}))(\\w[\\w\\d]*)([^/>]*(?!/)>)[^<]*$`, 'i'),
action: { indentAction: IndentAction.Indent }
//.........這裏部分代碼省略.........
示例10: activate
export function activate(context: ExtensionContext) {
console.log('Activating Java');
// Options to control the language client
let clientOptions: LanguageClientOptions = {
// Register the server for java documents
documentSelector: ['java'],
synchronize: {
// Synchronize the setting section 'java' to the server
// NOTE: this currently doesn't do anything
configurationSection: 'java',
// Notify the server about file changes to 'javaconfig.json' files contain in the workspace
fileEvents: [
workspace.createFileSystemWatcher('**/javaconfig.json'),
workspace.createFileSystemWatcher('**/pom.xml'),
workspace.createFileSystemWatcher('**/WORKSPACE'),
workspace.createFileSystemWatcher('**/BUILD'),
workspace.createFileSystemWatcher('**/*.java')
]
},
outputChannelName: 'Java',
revealOutputChannelOn: 4 // never
}
let launcherRelativePath = platformSpecificLauncher();
let launcherPath = [context.extensionPath].concat(launcherRelativePath);
let launcher = Path.resolve(...launcherPath);
console.log(launcher);
// Start the child java process
let serverOptions: ServerOptions = {
command: launcher,
args: [],
options: { cwd: context.extensionPath }
}
if (visualVm) {
serverOptions = visualVmConfig(context);
}
// Copied from typescript
languages.setLanguageConfiguration('java', {
indentationRules: {
// ^(.*\*/)?\s*\}.*$
decreaseIndentPattern: /^((?!.*?\/\*).*\*\/)?\s*[\}\]\)].*$/,
// ^.*\{[^}"']*$
increaseIndentPattern: /^((?!\/\/).)*(\{[^}"'`]*|\([^)"'`]*|\[[^\]"'`]*)$/,
indentNextLinePattern: /^\s*(for|while|if|else)\b(?!.*[;{}]\s*(\/\/.*|\/[*].*[*]\/\s*)?$)/
},
onEnterRules: [
{
// e.g. /** | */
beforeText: /^\s*\/\*\*(?!\/)([^\*]|\*(?!\/))*$/,
afterText: /^\s*\*\/$/,
action: { indentAction: IndentAction.IndentOutdent, appendText: ' * ' }
}, {
// e.g. /** ...|
beforeText: /^\s*\/\*\*(?!\/)([^\*]|\*(?!\/))*$/,
action: { indentAction: IndentAction.None, appendText: ' * ' }
}, {
// e.g. * ...|
beforeText: /^(\t|(\ \ ))*\ \*(\ ([^\*]|\*(?!\/))*)?$/,
action: { indentAction: IndentAction.None, appendText: '* ' }
}, {
// e.g. */|
beforeText: /^(\t|(\ \ ))*\ \*\/\s*$/,
action: { indentAction: IndentAction.None, removeText: 1 }
},
{
// e.g. *-----*/|
beforeText: /^(\t|(\ \ ))*\ \*[^/]*\*\/\s*$/,
action: { indentAction: IndentAction.None, removeText: 1 }
}
]
})
// Create the language client and start the client.
let client = new LanguageClient('java', 'Java Language Server', serverOptions, clientOptions);
let disposable = client.start();
// Push the disposable to the context's subscriptions so that the
// client can be deactivated on extension deactivation
context.subscriptions.push(disposable);
// Register test commands
commands.registerCommand('java.command.test.run', runTest);
commands.registerCommand('java.command.findReferences', runFindReferences);
// When the language client activates, register a progress-listener
client.onReady().then(() => createProgressListeners(client));
}