Skip to content

Commit 4181af8

Browse files
committed
Simple streaming
1 parent 56519df commit 4181af8

File tree

3 files changed

+55
-2
lines changed

3 files changed

+55
-2
lines changed

client/clientMain.ts

+27-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as path from 'path'
22
import * as vscode from 'vscode'
3+
import * as WebSocket from 'ws'
34

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

16+
const config = vscode.workspace.getConfiguration('mls.debug.log')
17+
let socket: WebSocket = undefined;
18+
if (config) {
19+
if (config.output === 'websocket' && config.port) {
20+
socket = new WebSocket(`ws://localhost:${config.get('port')}`)
21+
}
22+
}
23+
1524
const serverOptions: ServerOptions = {
1625
run: { module: serverModule, transport: TransportKind.ipc },
1726
debug: {
@@ -28,11 +37,28 @@ export function activate(context: vscode.ExtensionContext) {
2837
],
2938
synchronize: {
3039
configurationSection: []
31-
}
40+
},
41+
outputChannel: socket ? socketToChannel(socket) : undefined
3242
}
3343

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

3646
const disposable = client.start()
3747
context.subscriptions.push(disposable)
3848
}
49+
50+
const socketToChannel = (socket: WebSocket): vscode.OutputChannel => {
51+
return {
52+
name: 'websocket',
53+
append(value: string) {
54+
socket.send(value)
55+
},
56+
appendLine(value: string) {
57+
socket.send(value)
58+
},
59+
clear() {},
60+
show() {},
61+
hide() {},
62+
dispose() {}
63+
}
64+
}

package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
"dependencies": {
1919
"prettier": "^1.11.1",
2020
"vscode-languageclient": "^4.0.0",
21-
"vscode-languageserver-types": "^3.6.0"
21+
"vscode-languageserver-types": "^3.6.0",
22+
"ws": "^6.0.0"
2223
},
2324
"activationEvents": [
2425
"onLanguage:markdown"
@@ -27,6 +28,7 @@
2728
"contributes": {},
2829
"devDependencies": {
2930
"@types/node": "^9.4.6",
31+
"@types/ws": "^6.0.0",
3032
"npm-run-all": "^4.1.3",
3133
"tslint": "^5.9.1",
3234
"typescript": "^2.7.2",

yarn.lock

+25
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,25 @@
22
# yarn lockfile v1
33

44

5+
"@types/events@*":
6+
version "1.2.0"
7+
resolved "https://registry.yarnpkg.com/@types/events/-/events-1.2.0.tgz#81a6731ce4df43619e5c8c945383b3e62a89ea86"
8+
9+
"@types/node@*":
10+
version "10.7.1"
11+
resolved "https://registry.yarnpkg.com/@types/node/-/node-10.7.1.tgz#b704d7c259aa40ee052eec678758a68d07132a2e"
12+
513
"@types/node@^9.4.6":
614
version "9.4.6"
715
resolved "https://registry.yarnpkg.com/@types/node/-/node-9.4.6.tgz#d8176d864ee48753d053783e4e463aec86b8d82e"
816

17+
"@types/ws@^6.0.0":
18+
version "6.0.0"
19+
resolved "https://registry.yarnpkg.com/@types/ws/-/ws-6.0.0.tgz#4787c4194c29cc6361208dcf4e580e208794e012"
20+
dependencies:
21+
"@types/events" "*"
22+
"@types/node" "*"
23+
924
ajv@^5.1.0:
1025
version "5.5.2"
1126
resolved "https://registry.yarnpkg.com/ajv/-/ajv-5.5.2.tgz#73b5eeca3fab653e3d3f9422b341ad42205dc965"
@@ -101,6 +116,10 @@ assert-plus@^0.2.0:
101116
version "0.2.0"
102117
resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-0.2.0.tgz#d74e1b87e7affc0db8aadb7021f3fe48101ab234"
103118

119+
async-limiter@~1.0.0:
120+
version "1.0.0"
121+
resolved "https://registry.yarnpkg.com/async-limiter/-/async-limiter-1.0.0.tgz#78faed8c3d074ab81f22b4e985d79e8738f720f8"
122+
104123
asynckit@^0.4.0:
105124
version "0.4.0"
106125
resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79"
@@ -2058,6 +2077,12 @@ wrappy@1:
20582077
version "1.0.2"
20592078
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
20602079

2080+
ws@^6.0.0:
2081+
version "6.0.0"
2082+
resolved "https://registry.yarnpkg.com/ws/-/ws-6.0.0.tgz#eaa494aded00ac4289d455bac8d84c7c651cef35"
2083+
dependencies:
2084+
async-limiter "~1.0.0"
2085+
20612086
"xtend@>=4.0.0 <4.1.0-0", xtend@^4.0.0, xtend@~4.0.0, xtend@~4.0.1:
20622087
version "4.0.1"
20632088
resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.1.tgz#a5c6d532be656e23db820efb943a1f04998d63af"

0 commit comments

Comments
 (0)