How to use vscode-languageclient - 10 common examples

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 tintoy / msbuild-project-tools-vscode / src / extension / extension.ts View on Github external
error: (error, message, count) => {
                if (count > 2)  // Don't be annoying
                    return ErrorAction.Shutdown;

                console.log(message);
                console.log(error);

                if (message)
                    outputChannel.appendLine(`The MSBuild language server encountered an unexpected error: ${message}\n\n${error}`);
                else
                    outputChannel.appendLine(`The MSBuild language server encountered an unexpected error.\n\n${error}`);

                return ErrorAction.Continue;
            },
            closed: () => CloseAction.DoNotRestart
github vladdu / vscode-erlang-lsp / src / extension.ts View on Github external
vscode.workspace.createFileSystemWatcher('**/*.app.src'),
                vscode.workspace.createFileSystemWatcher('**/rebar.config')
            ]
        }
    }

    let escriptPath = await getEscriptPath()

    // Create the language client and start it.
    let client = new LanguageClient('Erlang Server',
        () => {
            return startServer(extensionPath, escriptPath, channel)
        },
        clientOptions)
    client.registerProposedFeatures();
    client.trace = Trace.Verbose;
    client.onReady().then(() => { console.log('Erlang server ready!') },
        (reason) => { throw Error('Erlang server error:  ' + reason) })
    return 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 apazureck / openui5vscodeTypescriptTools / client / src / extension.ts View on Github external
return new Promise((resolve, reject) => {
        // The server is implemented in node
        log.printInfo("Staring XML View language server");
        const serverModule = c.asAbsolutePath(path.join("server", "server.js"));
        // The debug options for the server
        const debugOptions = { storagepath: c.asAbsolutePath("schemastore"), execArgv: ["--nolazy", "--debug=6009"] };

        // If the extension is launched in debug mode then the debug server options are used
        // Otherwise the run options are used
        const serverOptions: ServerOptions = {
            debug: { module: serverModule, transport: TransportKind.ipc, options: debugOptions },
            run: { module: serverModule, transport: TransportKind.ipc },
        };

        // Options to control the language client
        const clientOptions: LanguageClientOptions = {
            // Register the server for xml decuments documents
            diagnosticCollectionName: "xmlDiagnostics",
            documentSelector: ["xml", "xsd"],
            initializationOptions: { storagepath: c.asAbsolutePath("schemastore") },
            synchronize: {
                // Synchronize the setting section "languageServerExample" to the server
                configurationSection: "ui5ts",
                // Notify the server about file changes to '.clientrc files contain in the workspace
                fileEvents: workspace.createFileSystemWatcher("**/*.{xml,xsd}", false, false, false),
            },
        };