Skip to content

Commit

Permalink
Simple streaming
Browse files Browse the repository at this point in the history
  • Loading branch information
octref committed Aug 20, 2018
1 parent 56519df commit 4181af8
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 2 deletions.
28 changes: 27 additions & 1 deletion client/clientMain.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as path from 'path'
import * as vscode from 'vscode'
import * as WebSocket from 'ws'

import {
LanguageClient,
Expand All @@ -12,6 +13,14 @@ export function activate(context: vscode.ExtensionContext) {
const serverModule = context.asAbsolutePath(path.join('server', 'dist', 'serverMain.js'))
const debugOptions = { execArgv: ['--nolazy', '--inspect=6006'] }

const config = vscode.workspace.getConfiguration('mls.debug.log')
let socket: WebSocket = undefined;
if (config) {
if (config.output === 'websocket' && config.port) {
socket = new WebSocket(`ws://localhost:${config.get('port')}`)
}
}

const serverOptions: ServerOptions = {
run: { module: serverModule, transport: TransportKind.ipc },
debug: {
Expand All @@ -28,11 +37,28 @@ export function activate(context: vscode.ExtensionContext) {
],
synchronize: {
configurationSection: []
}
},
outputChannel: socket ? socketToChannel(socket) : undefined
}

const client = new LanguageClient('mls', 'Markdown Language Server', serverOptions, clientOptions)

const disposable = client.start()
context.subscriptions.push(disposable)
}

const socketToChannel = (socket: WebSocket): vscode.OutputChannel => {
return {
name: 'websocket',
append(value: string) {
socket.send(value)
},
appendLine(value: string) {
socket.send(value)
},
clear() {},
show() {},
hide() {},
dispose() {}
}
}
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"dependencies": {
"prettier": "^1.11.1",
"vscode-languageclient": "^4.0.0",
"vscode-languageserver-types": "^3.6.0"
"vscode-languageserver-types": "^3.6.0",
"ws": "^6.0.0"
},
"activationEvents": [
"onLanguage:markdown"
Expand All @@ -27,6 +28,7 @@
"contributes": {},
"devDependencies": {
"@types/node": "^9.4.6",
"@types/ws": "^6.0.0",
"npm-run-all": "^4.1.3",
"tslint": "^5.9.1",
"typescript": "^2.7.2",
Expand Down
25 changes: 25 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,25 @@
# yarn lockfile v1


"@types/events@*":
version "1.2.0"
resolved "https://registry.yarnpkg.com/@types/events/-/events-1.2.0.tgz#81a6731ce4df43619e5c8c945383b3e62a89ea86"

"@types/node@*":
version "10.7.1"
resolved "https://registry.yarnpkg.com/@types/node/-/node-10.7.1.tgz#b704d7c259aa40ee052eec678758a68d07132a2e"

"@types/node@^9.4.6":
version "9.4.6"
resolved "https://registry.yarnpkg.com/@types/node/-/node-9.4.6.tgz#d8176d864ee48753d053783e4e463aec86b8d82e"

"@types/ws@^6.0.0":
version "6.0.0"
resolved "https://registry.yarnpkg.com/@types/ws/-/ws-6.0.0.tgz#4787c4194c29cc6361208dcf4e580e208794e012"
dependencies:
"@types/events" "*"
"@types/node" "*"

ajv@^5.1.0:
version "5.5.2"
resolved "https://registry.yarnpkg.com/ajv/-/ajv-5.5.2.tgz#73b5eeca3fab653e3d3f9422b341ad42205dc965"
Expand Down Expand Up @@ -101,6 +116,10 @@ assert-plus@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-0.2.0.tgz#d74e1b87e7affc0db8aadb7021f3fe48101ab234"

async-limiter@~1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/async-limiter/-/async-limiter-1.0.0.tgz#78faed8c3d074ab81f22b4e985d79e8738f720f8"

asynckit@^0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79"
Expand Down Expand Up @@ -2058,6 +2077,12 @@ wrappy@1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"

ws@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/ws/-/ws-6.0.0.tgz#eaa494aded00ac4289d455bac8d84c7c651cef35"
dependencies:
async-limiter "~1.0.0"

"xtend@>=4.0.0 <4.1.0-0", xtend@^4.0.0, xtend@~4.0.0, xtend@~4.0.1:
version "4.0.1"
resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.1.tgz#a5c6d532be656e23db820efb943a1f04998d63af"
Expand Down

0 comments on commit 4181af8

Please sign in to comment.