TS + Rust Integration

Rust Lang Server reads from stdin
Client invokes the language server and sends requests
It works!
This commit is contained in:
Noah Santschi-Cooney 2020-02-14 23:14:29 +00:00
parent b4a19265f8
commit 17f65ec5cf
No known key found for this signature in database
GPG key ID: 3B22282472C8AE48
9 changed files with 80 additions and 107 deletions

View file

@ -3,34 +3,38 @@ import * as vscode from 'vscode'
import * as vscodeLang from 'vscode-languageclient'
export async function activate(context: vscode.ExtensionContext) {
const serverModule = context.asAbsolutePath(path.join('server', 'out', 'server.js'))
const debugOpts = { execArgv: ['--nolazy', '--inspect=6009']}
const serverOpts: vscodeLang.ServerOptions = {
run: {
module: serverModule, transport: vscodeLang.TransportKind.ipc
},
debug: {
module: serverModule, transport: vscodeLang.TransportKind.ipc, options: debugOpts
}
}
const outputChannel = vscode.window.createOutputChannel('vscode-mc-shader')
const clientOpts: vscodeLang.LanguageClientOptions = {
documentSelector: [{scheme: 'file', language: 'glsl'}],
outputChannel: outputChannel,
outputChannelName: 'vscode-mc-shader',
synchronize: {
configurationSection: 'mcglsl',
fileEvents: vscode.workspace.createFileSystemWatcher('**/*.{fsh,gsh,vsh,glsl}')
}
},
}
const serverOpts: vscodeLang.ServerOptions = {
command: context.asAbsolutePath(path.join('server', 'target', 'debug', 'vscode-mc-shader')),
}
outputChannel.appendLine('starting language server...')
const langServer = new vscodeLang.LanguageClient('vscode-mc-shader', serverOpts, clientOpts)
context.subscriptions.push(langServer.start())
await langServer.onReady()
langServer.onNotification('sampleText', (...nums: number[]) => {
outputChannel.appendLine(`got notif: ${nums.join(' ')}`)
})
langServer.onNotification('update-config', (dir: string) => {
vscode.workspace.getConfiguration().update('mcglsl.glslangValidatorPath', dir, vscode.ConfigurationTarget.Global)
})
outputChannel.appendLine('language server started!')
}