How to use the vscode-languageclient.LanguageClient function in vscode-languageclient

To help you get started, we’ve selected a few vscode-languageclient examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github alesiong / clang-tidy-linter / src / extension.ts View on Github external
run: { module: serverModule, transport: TransportKind.ipc },
        debug: { module: serverModule, transport: TransportKind.ipc, options: debugOptions }
    };

    const clientOptions: LanguageClientOptions = {
        documentSelector: [
            { scheme: 'file', language: 'cpp' },
            { scheme: 'file', language: 'c'},
        ],
        synchronize: {
            fileEvents: workspace.createFileSystemWatcher('**/*'),
        }
    };

    // Create the language client and start the client.
    client = new LanguageClient('clangTidy', 'Clang Tidy Linter Client',
        serverOptions, clientOptions);

    console.log('start');
    client.start();
}
github alanz / vscode-hie-server / src / extension.ts View on Github external
// Notify the server about file changes to '.clientrc files contain in the workspace.
      fileEvents: workspace.createFileSystemWatcher('**/.clientrc')
    },
    diagnosticCollectionName: langName,
    revealOutputChannelOn: RevealOutputChannelOn.Never,
    outputChannel,
    outputChannelName: langName,
    middleware: {
      provideHover: DocsBrowser.hoverLinksMiddlewareHook
    },
    // Set the current working directory, for HIE, to be the workspace folder.
    workspaceFolder: folder
  };

  // Create the LSP client.
  const langClient = new LanguageClient(langName, langName, serverOptions, clientOptions, true);

  // Register ClientCapabilities for stuff like window/progress
  langClient.registerProposedFeatures();

  if (workspace.getConfiguration('languageServerHaskell', uri).showTypeForSelection.onHover) {
    context.subscriptions.push(ShowTypeHover.registerTypeHover(clients));
  }
  // Register editor commands for HIE, but only register the commands once.
  if (!hieCommandsRegistered) {
    context.subscriptions.push(InsertType.registerCommand(clients));
    const showTypeCmd = ShowTypeCommand.registerCommand(clients);
    if (showTypeCmd !== null) {
      showTypeCmd.forEach(x => context.subscriptions.push(x));
    }
    context.subscriptions.push(ImportIdentifier.registerCommand());
    registerHiePointCommand('hie.commands.demoteDef', 'hare:demote', context);
github kythe / kythe / kythe / typescript / languageserver / vscode-extension / src / extension.ts View on Github external
export function activate(context: ExtensionContext) {
  const debugOptions = {execArgv: ['--nolazy', '--debug=6004']};
  const settings = workspace.getConfiguration('kytheLanguageServer');

  const serverOptions: ServerOptions = {
    command: settings.get('bin') || 'kythe_languageserver',
    args: settings.get('args'),
  };

  const clientOptions: LanguageClientOptions = {
    // Activate on all files and defer to the server to ignore stuff
    documentSelector: [{pattern: '**/*'}]
  }

  const disposable = new LanguageClient(
                         'kytheLanguageServer', 'Kythe Language Server',
                         serverOptions, clientOptions)
                         .start();

  context.subscriptions.push(disposable);
}
github microsoft / vscode-extension-samples / languageprovider-sample / client / src / clientMain.ts View on Github external
}

	// Options to control the language client
	let clientOptions: LanguageClientOptions = {
		// Register the server for plain text documents
		documentSelector: ['plaintext'],
		synchronize: {
			// Synchronize the setting section 'languageServerExample' to the server
			configurationSection: 'languageServerExample',
			// 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 disposable = new LanguageClient('languageServerExample', 'Language Server Example', serverOptions, clientOptions).start();

	// Push the disposable to the context's subscriptions so that the 
	// client can be deactivated on extension deactivation
	context.subscriptions.push(disposable);
}
github Dart-Code / Dart-Code / src / extension / lsp / setup.ts View on Github external
async function startLsp(logger: Logger, sdks: Sdks): Promise {
	const clientOptions: LanguageClientOptions = {
		initializationOptions: {
			// 	onlyAnalyzeProjectsWithOpenFiles: true,
			closingLabels: config.closingLabels,
		},
		outputChannelName: "LSP",
	};

	lspClient = new LanguageClient(
		"dartAnalysisLSP",
		"Dart Analysis Server",
		() => spawn(logger, sdks),
		clientOptions,
	);

	return lspClient.start();
}
github bmewburn / vscode-intelephense / src / extension.ts View on Github external
isVscode: true
	};

	// Options to control the language client
	let clientOptions: LanguageClientOptions = {
		documentSelector: [
			{ language: PHP_LANGUAGE_ID, scheme: 'file' },
			{ language: PHP_LANGUAGE_ID, scheme: 'untitled' }
		],
        initializationOptions: initializationOptions,
        revealOutputChannelOn: RevealOutputChannelOn.Never,
		middleware: middleware
	}

	// Create the language client and start the client.
	languageClient = new LanguageClient('intelephense', 'intelephense', serverOptions, clientOptions);
	languageClient.onReady().then(() => {
		registerNotificationListeners();
		showStartMessage(context);
	});
	return languageClient;
}
github microsoft / vscode-lsif-extension / client / src / extension.ts View on Github external
// 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 = {
	};

	// Create the language client and start the client.
	client = new LanguageClient(
		'lsif',
		'Language Server Index Format',
		serverOptions,
		clientOptions
	);

	// Start the client. This will also launch the server
	client.start();

	let clientPromise = new Promise((resolve, reject) => {
		client.onReady().then(() => {
			resolve(client);
		}, (error) => {
			reject(error);
		})
	});
github HTML-as-programming-language / HTML-as-programming-language / vscode / src / extension.ts View on Github external
function startLangServer() {

    const serverOptions: ServerOptions = {
        command: "htmlclangsvr"
	};
	const clientOptions: LanguageClientOptions = {
		documentSelector: ["html"]
	}

    client = new LanguageClient("htmlc", serverOptions, clientOptions);
    client.start();
}
github BowlerHatLLC / vscode-as3mxml / vscode-extension / src / main / ts / extension.ts View on Github external
{
				primaryWorkspaceFolder = vscode.workspace.workspaceFolders[0];
			}
			//uncomment to allow a debugger to attach to the language server
			//args.unshift("-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005,quiet=y");
			let executable: Executable =
			{
				command: javaExecutablePath,
				args: args,
				options:
				{
					cwd: primaryWorkspaceFolder ? vscode.workspace.workspaceFolders[0].uri.fsPath : undefined
				}
			};
			isLanguageClientReady = false;
			savedLanguageClient = new LanguageClient("actionscript", "ActionScript & MXML Language Server", executable, clientOptions);
			savedLanguageClient.onReady().then(() =>
			{
				resolve();
				isLanguageClientReady = true;
				savedLanguageClient.onNotification("as3mxml/logCompilerShellOutput", (notification: string) =>
				{
					logCompilerShellOutput(notification, false, false);
				});
				savedLanguageClient.onNotification("as3mxml/clearCompilerShellOutput", () =>
				{
					logCompilerShellOutput(null, false, true);
				});
				if(pendingQuickCompileAndDebug)
				{
					vscode.commands.executeCommand("as3mxml.quickCompileAndDebug");
				}
github slackhq / vscode-hack / src / LSPHHASTLint.ts View on Github external
public async run(): Promise {
    const initializationOptions: InitializationOptions = {};
    const lintMode = config.hhastLintMode;
    if (lintMode) {
      initializationOptions.lintMode = lintMode;
    }

    const hhast = new LanguageClient(
      'hack',
      'HHAST',
      {
        command: remote.getCommand(this.hhastPath),
        args: remote.getArgs(this.hhastPath, [...config.hhastArgs, '--mode', 'lsp', '--from', 'vscode-hack'])
      },
      {
        documentSelector: [{ language: 'hack', scheme: 'file' }],
        initializationOptions: initializationOptions,
        uriConverters: { code2Protocol: utils.mapFromWorkspaceUri, protocol2Code: utils.mapToWorkspaceUri },
        middleware: {
          handleDiagnostics: this.handleDiagnostics
        }
      }
    );
    this.context.subscriptions.push(hhast.start());