summaryrefslogtreecommitdiff
path: root/client/src
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-08-29 00:27:18 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-08-29 00:27:18 +0800
commita3069a5187761a56ca0c51f2fc2d6bcf0a1d1c4b (patch)
treec4e94ea0879bc0f2dd4a5ccb83c8a7512668b7c6 /client/src
parentf4d1b0210a63a91965198f2042750333882fadaa (diff)
downloadlua-language-server-a3069a5187761a56ca0c51f2fc2d6bcf0a1d1c4b.zip
分平台启动
Diffstat (limited to 'client/src')
-rw-r--r--client/src/extension.ts51
1 files changed, 34 insertions, 17 deletions
diff --git a/client/src/extension.ts b/client/src/extension.ts
index db9cbdda..12418c14 100644
--- a/client/src/extension.ts
+++ b/client/src/extension.ts
@@ -4,6 +4,7 @@
* ------------------------------------------------------------------------------------------ */
import * as path from 'path';
+import * as os from 'os';
import { workspace, ExtensionContext, env } from 'vscode';
import {
@@ -11,18 +12,46 @@ import {
LanguageClientOptions,
ServerOptions,
} from 'vscode-languageclient';
+import { openSync } from 'fs';
let client: LanguageClient;
export function activate(context: ExtensionContext) {
let language = env.language;
- // If the extension is launched in debug mode then the debug server options are used
- // Otherwise the run options are used
+ // Options to control the language client
+ let clientOptions: LanguageClientOptions = {
+ // Register the server for plain text documents
+ documentSelector: [{ scheme: 'file', language: 'lua' }],
+ synchronize: {
+ // Notify the server about file changes to '.clientrc files contained in the workspace
+ fileEvents: workspace.createFileSystemWatcher('**/.clientrc')
+ }
+ };
+
+ let command: string;
+ let platform: string = os.platform();
+ switch (platform) {
+ case "win32":
+ command = context.asAbsolutePath(
+ path.join('server', 'Windows', 'bin', 'lua-language-server.exe')
+ );
+ break;
+ case "linux":
+ command = context.asAbsolutePath(
+ path.join('server', 'Linux', 'bin', 'lua-language-server')
+ );
+ break;
+
+ case "darwin":
+ command = context.asAbsolutePath(
+ path.join('server', 'Macos', 'bin', 'lua-language-server')
+ );
+ break;
+ }
+
let serverOptions: ServerOptions = {
- command: context.asAbsolutePath(
- path.join('server', 'Windows', 'bin', 'lua-language-server')
- ),
+ command: command,
args: [
'-E',
'-e',
@@ -33,17 +62,6 @@ export function activate(context: ExtensionContext) {
]
};
- // Options to control the language client
- let clientOptions: LanguageClientOptions = {
- // Register the server for plain text documents
- documentSelector: [{ scheme: 'file', language: 'lua' }],
- synchronize: {
- // Notify the server about file changes to '.clientrc files contained in the workspace
- fileEvents: workspace.createFileSystemWatcher('**/.clientrc')
- }
- };
-
- // Create the language client and start the client.
client = new LanguageClient(
'Lua Language Server',
'Lua Language Client',
@@ -51,7 +69,6 @@ export function activate(context: ExtensionContext) {
clientOptions
);
- // Start the client. This will also launch the server
client.start();
}