當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript vscode-languageclient.LanguageClient類代碼示例

本文整理匯總了TypeScript中vscode-languageclient.LanguageClient的典型用法代碼示例。如果您正苦於以下問題:TypeScript LanguageClient類的具體用法?TypeScript LanguageClient怎麽用?TypeScript LanguageClient使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了LanguageClient類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: startLanguageClient

async function startLanguageClient(context: ExtensionContext) {
    let cfg = vscode.workspace.getConfiguration("wurst")

    let clientOptions: LanguageClientOptions = {
		// Register the server for Wurst-documents
		documentSelector: ['wurst'],
		synchronize: {
			// Synchronize the setting section 'wurst' to the server
			configurationSection: 'wurst',
            // Notify the server about file changes to '.wurst files contain in the workspace
            // currently disabled, because not working
            // using manual workaround in registerFileChanges instead
			// fileEvents: workspace.createFileSystemWatcher('**/*.wurst')
		}
    }

    let serverOptions = await getServerOptions();

    let client = new LanguageClient("wurstLanguageServer", serverOptions, clientOptions);
    context.subscriptions.push(client.start());

    context.subscriptions.push(registerCommands(client));
    context.subscriptions.push(registerFileCreation());
    context.subscriptions.push(registerFileChanges(client));
}
開發者ID:peq,項目名稱:wurst4vscode,代碼行數:25,代碼來源:extension.ts

示例2: activate

export function activate(context: ExtensionContext) {

	let config = workspace.getConfiguration("gluon");
	let serverPath = config.get("language-server.path", "gluon_language-server");
	
	// If the extension is launched in debug mode then the debug server options are used
	// Otherwise the run options are used
	let serverOptions: ServerOptions = {
		command : serverPath,
		args: [],
		options: {}
	}

	// Options to control the language client
	let clientOptions: LanguageClientOptions = {
		// Register the server for plain text documents
		documentSelector: ['gluon'],
		synchronize: {
			// Synchronize the setting section 'languageServerExample' to the server
			configurationSection: 'gluon',
			// Notify the server about file changes to '.clientrc files contain in the workspace
			fileEvents: workspace.createFileSystemWatcher('**/.clientrc')
		}
	}
	
	// Create the language client and start the client.
	let client = new LanguageClient('gluon', 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);
}
開發者ID:Marwes,項目名稱:gluon_language-server,代碼行數:33,代碼來源:extension.ts

示例3: activate

export function activate(context: ExtensionContext)
{
    let qol: QualityOfLife = new QualityOfLife();

    let serverModule = context.asAbsolutePath(path.join("server", "server.js"));
    let debugOptions = { execArgv: ["--nolazy", "--debug=6004"] };

    let serverOptions: ServerOptions = {
        run : { module: serverModule, transport: TransportKind.ipc },
        debug: { module: serverModule, transport: TransportKind.ipc, options: debugOptions }
    }

    let clientOptions: LanguageClientOptions = {
        documentSelector: ["php"],
        synchronize: {
            configurationSection: "languageServerExample",
            fileEvents: workspace.createFileSystemWatcher("**/.clientrc")
        }
    }

    // Create the language client and start the client.
    var langClient: LanguageClient = new LanguageClient("Crane Language Server", serverOptions, clientOptions);

    // Use this to handle a request sent from the server
    // https://github.com/Microsoft/vscode/blob/80bd73b5132268f68f624a86a7c3e56d2bbac662/extensions/json/client/src/jsonMain.ts
    // https://github.com/Microsoft/vscode/blob/580d19ab2e1fd6488c3e515e27fe03dceaefb819/extensions/json/server/src/server.ts
    //langClient.onRequest()

    let disposable = langClient.start();

    let crane: Crane = new Crane(langClient);

    var requestType: RequestType<any, any, any> = { method: "workDone" };
    langClient.onRequest(requestType, () => {
        // Load settings
        let craneSettings = workspace.getConfiguration("crane");
        if (craneSettings) {
            var showStatusBarItem = craneSettings.get<boolean>("showStatusBarBugReportLink", true);
            if (showStatusBarItem) {
                setTimeout(() => {
                    crane.statusBarItem.text = "$(bug) Report PHP Intellisense Bug";
                    crane.statusBarItem.tooltip = "Found a problem with the PHP Intellisense provided by Crane? Click here to file a bug report on Github";
                    crane.statusBarItem.command = "crane.reportBug";
                    crane.statusBarItem.show();
                }, 5000);
            } else {
                crane.statusBarItem.hide();
            }
        } else {
            crane.statusBarItem.hide();
        }
    });

    // Register commands for QoL improvements
    let duplicateLineCommand = commands.registerCommand("crane.duplicateLine", qol.duplicateLineOrSelection);
    let reportBugCommand = commands.registerCommand("crane.reportBug", crane.reportBug);

    context.subscriptions.push(disposable);
    context.subscriptions.push(duplicateLineCommand);
}
開發者ID:TheColorRed,項目名稱:crane,代碼行數:60,代碼來源:extension.ts

示例4: handleServer

function* handleServer() {
  yield take(EXPRESS_SERVER_STARTED);
  const { context, childDevServerInfo: { port } }: ExtensionState = yield select();

  const serverOptions: ServerOptions = {
    run: { module: SERVER_MODULE_PATH, transport: TransportKind.ipc },
    debug: { module: SERVER_MODULE_PATH, transport: TransportKind.ipc, options: { execArgv: ["--nolazy", "--inspect=6005"]}}
  };

  const documentSelector = ["paperclip"];
  const config = workspace.getConfiguration();
  
  const clientOptions: LanguageClientOptions = {
    documentSelector,
    synchronize: {
      configurationSection: ["html", "paperclip", "tandem"]
    },
    initializationOptions: {
      devToolsPort: port
    }
  }

  const client = new LanguageClient("paperclip", "Paperclip Language Server", serverOptions, clientOptions);

  context.subscriptions.push(client.start());

}
開發者ID:cryptobuks,項目名稱:tandem,代碼行數:27,代碼來源:language-client.ts

示例5: activate

export function activate(context: ExtensionContext) {
    // Load the path to the language server from settings
    let executableCommand = workspace.getConfiguration("swift")
        .get("languageServerPath", "/usr/local/bin/LanguageServer");

    let run: Executable = { command: executableCommand };
    let debug: Executable = run;
    let serverOptions: ServerOptions = {
        run: run,
        debug: debug
    };
    
    // client extensions configure their server
    let clientOptions: LanguageClientOptions = {
        documentSelector: [
            { language: 'swift', scheme: 'file' },
            { language: 'swift', scheme: 'untitled' }
        ],
        synchronize: {
            configurationSection: 'swift',
            fileEvents: [
                workspace.createFileSystemWatcher('**/*.swift', false, true, false),
                workspace.createFileSystemWatcher('**/.build/{debug,release}.yaml', false, false, false)
            ]
        }
    }

    let client = new LanguageClient('Swift', serverOptions, clientOptions);

    // Push the disposable to the context's subscriptions so that the
    // client can be deactivated on extension deactivation
    context.subscriptions.push(client.start());
}
開發者ID:RLovelett,項目名稱:vscode-swift,代碼行數:33,代碼來源:extension.ts

示例6: 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());
}
開發者ID:karthiknadig,項目名稱:RTVS,代碼行數:35,代碼來源:extension.ts

示例7: 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());
}
開發者ID:olhotak,項目名稱:dotty,代碼行數:33,代碼來源:extension.ts

示例8: 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{}\[\],:]+/
	});
}
開發者ID:yuit,項目名稱:vscode,代碼行數:60,代碼來源:jsonMain.ts

示例9: activate

export function activate(context: vscode.ExtensionContext) {
	let config = RedConfiguration.getInstance();

	context.subscriptions.push(vscode.commands.registerCommand("red.interpret", () => redRunInConsole()));
	context.subscriptions.push(vscode.commands.registerCommand("red.interpretGUI", () => redRunInGuiConsole()));
	context.subscriptions.push(vscode.commands.registerCommand("red.compile", () => redCompileInConsole()));
	context.subscriptions.push(vscode.commands.registerCommand("red.compileGUI", () => redCompileInGuiConsole()));
	context.subscriptions.push(vscode.commands.registerCommand("reds.compile", () => redCompileInConsole()));
	context.subscriptions.push(vscode.commands.registerCommand("reds.compileGUI", () => redCompileInGuiConsole()));
	context.subscriptions.push(vscode.commands.registerCommand("red.commandMenu", setCommandMenu));

	console.log("Red console path: ", config.redConsole)
	let serverModule = path.join(context.asAbsolutePath("."), "server", "server.red");
	let needlog = "debug-off";
	if (config.needRlsDebug) {
		needlog = "debug-on";
	}
	console.log(needlog);
	const serverOptions: vscodelc.ServerOptions = {
		run : { command: config.redConsole, args: [serverModule, needlog]},
		debug: { command: config.redConsole, args: [serverModule, "debug-on"] }
	};
	const clientOptions: vscodelc.LanguageClientOptions = {
		documentSelector: [{scheme: 'file', language: 'red'}],
		initializationOptions: config.allConfigs || {},
		synchronize: {
			configurationSection: 'red'
		}
	}
	reddClient = new vscodelc.LanguageClient('red.server', 'Red Language Server', serverOptions, clientOptions);
	console.log('Red Language Server is now active!');
	context.subscriptions.push(reddClient.start());
}
開發者ID:red,項目名稱:VScode-extension,代碼行數:33,代碼來源:extension.ts

示例10: 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();
}
開發者ID:emuhedo,項目名稱:pyre-check,代碼行數:28,代碼來源:main.ts


注:本文中的vscode-languageclient.LanguageClient類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。