vscode-languageclient/node#RevealOutputChannelOn TypeScript Examples
The following examples show how to use
vscode-languageclient/node#RevealOutputChannelOn.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: client.ts From coffeesense with MIT License | 5 votes |
export function initializeLanguageClient(lspModulePath: string): LanguageClient {
const debugOptions = { execArgv: ['--nolazy', '--inspect=6005'] };
const documentSelector: DocumentFilter[] = [{ language: 'coffeescript', scheme: 'file' }];
const config = vscode.workspace.getConfiguration();
let serverPath;
const devLspPackagePath = config.get('coffeesense.dev.lspPath', '');
if (devLspPackagePath && devLspPackagePath !== '' && existsSync(devLspPackagePath)) {
serverPath = resolve(devLspPackagePath, 'dist/coffeescriptServerMain.js');
} else {
serverPath = lspModulePath;
}
const runExecArgv: string[] = [];
const lspPort = config.get('coffeesense.dev.lspPort');
if (lspPort !== -1) {
runExecArgv.push(`--inspect=${lspPort}`);
console.log(`Will launch LSP in port: ${lspPort}`);
}
const serverOptions: ServerOptions = {
run: { module: serverPath, transport: TransportKind.ipc, options: { execArgv: runExecArgv } },
debug: { module: serverPath, transport: TransportKind.ipc, options: debugOptions }
};
const clientOptions: LanguageClientOptions = {
documentSelector,
synchronize: {
configurationSection: ['coffeesense', 'javascript', 'typescript', 'files.associations'],
fileEvents: vscode.workspace.createFileSystemWatcher('{**/*.js,**/*.ts,**/*.json}', false, false, true)
},
initializationOptions: {
},
revealOutputChannelOn: RevealOutputChannelOn.Never
};
return new LanguageClient('coffeesense', 'CoffeeSense Language Server', serverOptions, clientOptions);
}
Example #2
Source File: client.ts From vala-vscode with MIT License | 5 votes |
constructor(_context: ExtensionContext) {
this.config = workspace.getConfiguration('vala', window.activeTextEditor?.document.uri);
let serverModule = this.languageServerPath;
if (serverModule == null)
return;
let clientOptions: LanguageClientOptions = {
documentSelector: ['vala', 'genie'],
revealOutputChannelOn: RevealOutputChannelOn.Info
};
// default environment in non-debug mode
let runEnvironment = { ...process.env };
if (this.config.debugMode)
runEnvironment['G_MESSAGES_DEBUG'] = 'all';
if (this.config.failOnCriticals)
runEnvironment['G_DEBUG'] = 'fatal-criticals';
let serverOptions: ServerOptions = {
run: {
command: serverModule,
transport: TransportKind.stdio,
options: {
env: runEnvironment
}
},
debug: {
command: serverModule,
options: {
env: {
...process.env,
G_MESSAGES_DEBUG: 'all'
}
},
transport: TransportKind.stdio
}
};
this.ls = new LanguageClient('Vala Language Server', serverOptions, clientOptions);
commands.registerTextEditorCommand('vala.showBaseSymbol', this.peekSymbol);
commands.registerTextEditorCommand('vala.showHiddenSymbol', this.peekSymbol);
this.ls.start();
}
Example #3
Source File: extension.ts From macro-executor with MIT License | 4 votes |
export function activate(context: ExtensionContext) {
// The server is implemented in node
let serverModule = context.asAbsolutePath(
path.join('server', 'out', 'server.js')
);
let debugOptions = { execArgv: ['--nolazy', '--inspect=6011'], cwd: process.cwd() };
let serverOptions: ServerOptions = {
run: { module: serverModule, transport: TransportKind.ipc, options: { cwd: process.cwd() } },
debug: {
module: serverModule,
transport: TransportKind.ipc,
options: debugOptions
}
};
let clientOptions: LanguageClientOptions = {
documentSelector: [{ language: 'macro', scheme: 'file' }],
initializationOptions: workspace.getConfiguration('macro'),
synchronize: {
fileEvents: workspace.createFileSystemWatcher('**/*.{[sS][rR][cC],[dD][eE][fF],[lL][nN][kK]}')
},
diagnosticCollectionName: 'macro',
progressOnInitialization: true,
revealOutputChannelOn: RevealOutputChannelOn.Never,
middleware: {
executeCommand: async (command:string, args:any[], next:ExecuteCommandSignature) => {
if (command === 'macro.codelens.references') {
const arg:CodeLensReferenceArgument = args[0];
const position = client.protocol2CodeConverter.asPosition(arg.position);
const locations:Location[] = [];
for (const location of arg.locations){
locations.push(client.protocol2CodeConverter.asLocation(location));
}
if (Window.activeTextEditor) {
commands.executeCommand('editor.action.showReferences', Window.activeTextEditor.document.uri, position, locations);
}
}
else if (command === 'macro.action.refactorsequeces' || command === 'macro.action.addsequeces') {
function validate(input:string): string | null {
return Number.isInteger(Number(input)) ? null : 'Integer expected';
}
const config = workspace.getConfiguration('macro');
let start = undefined;
if (command === 'macro.action.refactorsequeces') {
start = await Window.showInputBox({
prompt: 'Start sequence number',
value: config.sequence.base,
validateInput: validate
});
}
const increment = await Window.showInputBox({
prompt: 'Sequence number increment',
value: config.sequence.increment,
validateInput: validate
});
if (Window.activeTextEditor) {
if (command === 'macro.action.addsequeces' && increment) {
return next(command, [Window.activeTextEditor.document.uri.toString(), Window.activeTextEditor.selection.start, increment]);
}
else if (command === 'macro.action.refactorsequeces' && start && increment) {
return next(command, [Window.activeTextEditor.document.uri.toString(), Window.activeTextEditor.selection.start, start, increment]);
}
}
}
},
workspace : {
configuration: async (params, _token, _next): Promise<any[]> => {
if (params.items === undefined) {
return [];
}
const result: (ConfigurationSettings | null)[] = [];
for (const item of params.items) {
if (item.section || !item.scopeUri) {
result.push(null);
continue;
}
const resource = client.protocol2CodeConverter.asUri(item.scopeUri);
const workspaceFolder = Workspace.getWorkspaceFolder(resource);
const config = workspace.getConfiguration('macro', workspaceFolder);
const settings: ConfigurationSettings = {
codelens: config.get('codelens'),
lint:config.get('lint', {}),
sequence: config.get('sequence'),
validate: config.get('validate'),
keywords: config.get('keywords'),
};
if (workspaceFolder !== undefined) {
settings.workspaceFolder = {
name: workspaceFolder.name,
uri: client.code2ProtocolConverter.asUri(workspaceFolder.uri),
};
}
result.push(settings);
}
return result;
}
}
} as any
};
// Create the language client and start the client.
client = new LanguageClient(
'macroLanguageServer',
'Macro Language Server',
serverOptions,
clientOptions
);
disposables.add(registerCommands());
context.subscriptions.push(disposables);
context.subscriptions.push(client.start());
}