Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 900b0c6

Browse files
committed
Integrate vscode-client and server without install step
1 parent 787da9e commit 900b0c6

File tree

8 files changed

+646
-1659
lines changed

8 files changed

+646
-1659
lines changed

‎package.json‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
"devDependencies": {
1919
"@types/jest": "^22.2.2",
2020
"@types/node": "^9.6.2",
21-
"electron-rebuild": "^1.7.3",
2221
"jest": "^22.4.3",
2322
"prettier": "^1.11.1",
2423
"ts-jest": "^22.4.2",

‎server/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"license": "MIT",
66
"version": "1.6.1",
77
"publisher": "mads-hartmann",
8-
"main": "out/server.js",
8+
"main": "./out/server.js",
99
"typings": "./out/server.d.ts",
1010
"bin": {
1111
"bash-language-server": "./bin/main.js"

‎vscode-client/package.json‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"url": "https://github.com/mads-hartmann/bash-language-server"
1212
},
1313
"engines": {
14-
"vscode": "^1.18.x"
14+
"vscode": "^1.30.0"
1515
},
1616
"icon": "assets/bash-logo.png",
1717
"categories": [
@@ -57,9 +57,11 @@
5757
"postinstall": "vscode-install"
5858
},
5959
"dependencies": {
60-
"@types/semver-compare": "^1.0.0",
61-
"semver-compare": "^1.0.0",
62-
"vscode": "^1.1.14",
63-
"vscode-languageclient": "^4.1.3"
60+
"bash-language-server": "1.6.1",
61+
"vscode-languageclient": "^5.2.1",
62+
"vscode-languageserver": "^5.2.1"
63+
},
64+
"devDependencies": {
65+
"vscode": "^1.1.34"
6466
}
6567
}

‎vscode-client/src/extension.ts‎

Lines changed: 23 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,42 @@
11
'use strict'
2+
import * as path from 'path'
23

3-
import semverCompare = require('semver-compare')
4-
import { ExtensionContext, window, workspace } from 'vscode'
4+
import { ExtensionContext, workspace } from 'vscode'
55
import {
66
LanguageClient,
77
LanguageClientOptions,
88
ServerOptions,
9+
TransportKind,
910
} from 'vscode-languageclient'
1011

11-
import { getServerInfo } from './util'
12-
13-
const MINIMUM_SERVER_VERSION = '1.5.2'
14-
1512
export async function activate(context: ExtensionContext) {
16-
try {
17-
const { command, version } = await getServerInfo()
18-
if (semverCompare(version, MINIMUM_SERVER_VERSION) === -1) {
19-
return handleOutdatedExecutable()
20-
}
21-
22-
const explainshellEndpoint = workspace
23-
.getConfiguration('bashIde')
24-
.get('explainshellEndpoint', '')
13+
const explainshellEndpoint = workspace
14+
.getConfiguration('bashIde')
15+
.get('explainshellEndpoint', '')
2516

26-
const highlightParsingErrors = workspace
27-
.getConfiguration('bashIde')
28-
.get('highlightParsingErrors', false)
17+
const highlightParsingErrors = workspace
18+
.getConfiguration('bashIde')
19+
.get('highlightParsingErrors', false)
2920

30-
start(context, command, explainshellEndpoint, highlightParsingErrors)
31-
} catch (error) {
32-
handleStartError(error)
33-
}
34-
}
35-
36-
function start(
37-
context: ExtensionContext,
38-
command: string,
39-
explainshellEndpoint: string,
40-
highlightParsingErrors: boolean,
41-
) {
4221
const env: any = {
4322
...process.env,
4423
EXPLAINSHELL_ENDPOINT: explainshellEndpoint,
4524
HIGHLIGHT_PARSING_ERRORS: highlightParsingErrors,
4625
}
4726

48-
const serverOptions: ServerOptions = {
49-
run: {
50-
command,
51-
args: ['start'],
52-
options: {
53-
env,
54-
},
55-
},
56-
debug: {
57-
command,
58-
args: ['start'],
59-
options: {
60-
env,
61-
},
27+
const serverExecutable = {
28+
module: context.asAbsolutePath(path.join('out', 'src', 'server.js')),
29+
transport: TransportKind.ipc,
30+
options: {
31+
env,
6232
},
6333
}
6434

35+
const serverOptions: ServerOptions = {
36+
run: serverExecutable,
37+
debug: serverExecutable,
38+
}
39+
6540
const clientOptions: LanguageClientOptions = {
6641
documentSelector: [
6742
{
@@ -76,26 +51,11 @@ function start(
7651
},
7752
}
7853

79-
const disposable = new LanguageClient(
80-
'Bash IDE',
81-
'Bash IDE',
82-
serverOptions,
83-
clientOptions,
84-
).start()
54+
const client = new LanguageClient('Bash IDE', 'Bash IDE', serverOptions, clientOptions)
55+
56+
// client.registerProposedFeatures();
8557

8658
// Push the disposable to the context's subscriptions so that the
8759
// client can be deactivated on extension deactivation
88-
context.subscriptions.push(disposable)
89-
}
90-
91-
function handleOutdatedExecutable() {
92-
const message = `Outdated bash server. Please upgrade by running "npm i -g bash-language-server".`
93-
window.showErrorMessage(message, { modal: false })
94-
}
95-
96-
function handleStartError(error: Error) {
97-
const message =
98-
'Unable to start bash-language-server, did you install it by running "npm i -g bash-language-server"? Open DevTools for additional details.'
99-
console.error(error)
100-
window.showErrorMessage(message, { modal: false })
60+
context.subscriptions.push(client.start())
10161
}

‎vscode-client/src/server.ts‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import {
2+
createConnection,
3+
IConnection,
4+
InitializeParams,
5+
InitializeResult,
6+
ProposedFeatures,
7+
} from 'vscode-languageserver'
8+
9+
import BashLanguageServer from 'bash-language-server'
10+
11+
const connection: IConnection = createConnection(ProposedFeatures.all)
12+
13+
connection.onInitialize(async (params: InitializeParams): Promise<InitializeResult> => {
14+
connection.console.info('BashLanguageServer initializing...')
15+
16+
const server = await BashLanguageServer.initialize(connection, params)
17+
server.register(connection)
18+
19+
connection.console.info('BashLanguageServer initialized')
20+
21+
return {
22+
capabilities: server.capabilities(),
23+
}
24+
})
25+
26+
connection.listen()
27+
28+
// Don't die on unhandled Promise rejections
29+
process.on('unhandledRejection', (reason, p) => {
30+
connection.console.error(`Unhandled Rejection at promise: ${p}, reason: ${reason}`)
31+
})
32+
33+
process.on('SIGPIPE', () => {
34+
// Don't die when attempting to pipe stdin to a bad spawn
35+
// https://github.com/electron/electron/issues/13254
36+
})

‎vscode-client/src/util.ts‎

Lines changed: 0 additions & 42 deletions
This file was deleted.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /