-
Notifications
You must be signed in to change notification settings - Fork 132
/
Copy pathextension.ts
78 lines (66 loc) · 1.8 KB
/
extension.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
'use strict'
import * as path from 'path'
import { ExtensionContext, workspace } from 'vscode'
import {
LanguageClient,
LanguageClientOptions,
ServerOptions,
TransportKind,
} from 'vscode-languageclient/node'
let client: LanguageClient
export const CONFIGURATION_SECTION = 'bashIde' // matching the package.json configuration section
export async function activate(context: ExtensionContext) {
const config = workspace.getConfiguration(CONFIGURATION_SECTION)
const env: any = {
...process.env,
BASH_IDE_LOG_LEVEL: config.get('logLevel', ''),
}
const serverExecutable = {
module: context.asAbsolutePath(path.join('out', 'server.js')),
transport: TransportKind.ipc,
options: {
env,
},
}
const debugServerExecutable = {
...serverExecutable,
options: {
...serverExecutable.options,
execArgv: ['--nolazy', '--inspect=6009'],
},
}
const serverOptions: ServerOptions = {
run: serverExecutable,
debug: debugServerExecutable,
}
// NOTE: To debug a server running in a process, use the following instead:
// This requires the server to be globally installed.
// const serverOptions = {
// command: 'bash-language-server',
// args: ['start'],
// }
const clientOptions: LanguageClientOptions = {
documentSelector: [
{
scheme: 'file',
language: 'shellscript',
},
],
synchronize: {
configurationSection: CONFIGURATION_SECTION,
},
}
const client = new LanguageClient('Bash IDE', 'Bash IDE', serverOptions, clientOptions)
client.registerProposedFeatures()
try {
await client.start()
} catch (error) {
client.error(`Start failed`, error, 'force')
}
}
export function deactivate(): Thenable<void> | undefined {
if (!client) {
return undefined
}
return client.stop()
}