Link Search Menu Expand Document

Reference

export declare type ServerOptions = Executable | {
    run: Executable;
    debug: Executable;
} | {
    run: NodeModule;
    debug: NodeModule;
} | NodeModule | (() => Promise<ChildProcess | StreamInfo | MessageTransports | ChildProcessInfo>);

export interface Executable {
    command: string;
    args?: string[];
    options?: ExecutableOptions;
}

export interface StreamInfo {
    writer: NodeJS.WritableStream;
    reader: NodeJS.ReadableStream;
    detached?: boolean;
}

Examples

Example - lsp sample

let serverModule = context.asAbsolutePath(
    path.join('server', 'out', 'server.js')
);

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

client = new LanguageClient(
    'languageServerExample',
    'Language Server Example',
    serverOptions,
    clientOptions
);
client.start();

Example - solargraph

makeLanguageClient:

	let clientOptions: LanguageClientOptions = {
		documentSelector: [{scheme: 'file', language: 'ruby'}, {scheme: 'file', pattern: '**/Gemfile'}],
		synchronize: {
			// Synchronize the setting section 'solargraph' to the server
			configurationSection: 'solargraph',
			// Notify the server about changes to relevant files in the workspace
			fileEvents: vscode.workspace.createFileSystemWatcher('{**/*.rb,**/*.gemspec,**/Gemfile}')
		},
		middleware: middleware,
		initializationOptions: Object.assign({
			enablePages: true,
			viewsPath: vscode.extensions.getExtension('castwide.solargraph').extensionPath + '/views'
		}, vscode.workspace.getConfiguration('solargraph'))
    }

    let serverOptions: ServerOptions = selectClient();
import * as net from 'net';

selectClient: 
    transport = vscode.workspace.getConfiguration('solargraph').transport;
    if (transport == 'socket') {
        socketProvider: solargraph.SocketProvider = new solargraph.SocketProvider(configuration)
        socketProvider.start
        socket: net.Socket = net.createConnection(socketProvider.port);
    }
  • SocketProvider
start:
    solargraphCommand(['socket', '--port', '0'], this.configuration);

  • solargraphCommand
solargraphCommand

Table of contents


Copyright © 2020 Thence LLC