diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-08-29 00:27:18 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-08-29 00:27:18 +0800 |
commit | a3069a5187761a56ca0c51f2fc2d6bcf0a1d1c4b (patch) | |
tree | c4e94ea0879bc0f2dd4a5ccb83c8a7512668b7c6 | |
parent | f4d1b0210a63a91965198f2042750333882fadaa (diff) | |
download | lua-language-server-a3069a5187761a56ca0c51f2fc2d6bcf0a1d1c4b.zip |
分平台启动
-rw-r--r-- | client/out/extension.js | 36 | ||||
-rw-r--r-- | client/out/extension.js.map | 2 | ||||
-rw-r--r-- | client/src/extension.ts | 51 |
3 files changed, 58 insertions, 31 deletions
diff --git a/client/out/extension.js b/client/out/extension.js index 6fe820d8..38f1b83d 100644 --- a/client/out/extension.js +++ b/client/out/extension.js @@ -5,22 +5,12 @@ * ------------------------------------------------------------------------------------------ */ Object.defineProperty(exports, "__esModule", { value: true }); const path = require("path"); +const os = require("os"); const vscode_1 = require("vscode"); const vscode_languageclient_1 = require("vscode-languageclient"); let client; function activate(context) { let language = vscode_1.env.language; - // If the extension is launched in debug mode then the debug server options are used - // Otherwise the run options are used - let serverOptions = { - command: context.asAbsolutePath(path.join('server', 'Windows', 'bin', 'lua-language-server')), - args: [ - '-E', - '-e', - 'LANG="' + language + '"', - context.asAbsolutePath(path.join('server', 'main.lua')) - ] - }; // Options to control the language client let clientOptions = { // Register the server for plain text documents @@ -30,9 +20,29 @@ function activate(context) { fileEvents: vscode_1.workspace.createFileSystemWatcher('**/.clientrc') } }; - // Create the language client and start the client. + let command; + let platform = 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 = { + command: command, + args: [ + '-E', + '-e', + 'LANG="' + language + '"', + context.asAbsolutePath(path.join('server', 'main.lua')) + ] + }; client = new vscode_languageclient_1.LanguageClient('Lua Language Server', 'Lua Language Client', serverOptions, clientOptions); - // Start the client. This will also launch the server client.start(); } exports.activate = activate; diff --git a/client/out/extension.js.map b/client/out/extension.js.map index 241f960e..f78b2fb6 100644 --- a/client/out/extension.js.map +++ b/client/out/extension.js.map @@ -1 +1 @@ -{"version":3,"file":"extension.js","sourceRoot":"","sources":["../src/extension.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;AAEhG,6BAA6B;AAC7B,mCAA0D;AAE1D,iEAI+B;AAE/B,IAAI,MAAsB,CAAC;AAE3B,SAAgB,QAAQ,CAAC,OAAyB;IACjD,IAAI,QAAQ,GAAG,YAAG,CAAC,QAAQ,CAAC;IAE5B,oFAAoF;IACpF,qCAAqC;IACrC,IAAI,aAAa,GAAkB;QAClC,OAAO,EAAE,OAAO,CAAC,cAAc,CAC9B,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,qBAAqB,CAAC,CAC5D;QACD,IAAI,EAAE;YACL,IAAI;YACJ,IAAI;YACJ,QAAQ,GAAG,QAAQ,GAAG,GAAG;YACzB,OAAO,CAAC,cAAc,CACrB,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,CAC/B;SACD;KACD,CAAC;IAEF,yCAAyC;IACzC,IAAI,aAAa,GAA0B;QAC1C,+CAA+C;QAC/C,gBAAgB,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;QACvD,WAAW,EAAE;YACZ,sFAAsF;YACtF,UAAU,EAAE,kBAAS,CAAC,uBAAuB,CAAC,cAAc,CAAC;SAC7D;KACD,CAAC;IAEF,mDAAmD;IACnD,MAAM,GAAG,IAAI,sCAAc,CAC1B,qBAAqB,EACrB,qBAAqB,EACrB,aAAa,EACb,aAAa,CACb,CAAC;IAEF,qDA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AI,CAAC,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,qBAAqB,CAAC,CAC1D,CAAC;YACF,MAAM;KACP;IAED,IAAI,aAAa,GAAkB;QAClC,OAAO,EAAE,OAAO;QAChB,IAAI,EAAE;YACL,IAAI;YACJ,IAAI;YACJ,QAAQ,GAAG,QAAQ,GAAG,GAAG;YACzB,OAAO,CAAC,cAAc,CACrB,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,CAC/B;SACD;KACD,CAAC;IAEF,MAAM,GAAG,IAAI,sCAAc,CAC1B,qBAAqB,EACrB,qBAAqB,EACrB,aAAa,EACb,aAAa,CACb,CAAC;IAEF,MAAM,CAAC,KAAK,EAAE,CAAC;AAChB,CAAC;AAtDD,4BAsDC;AAED,SAAgB,UAAU;IACzB,IAAI,CAAC,MAAM,EAAE;QACZ,OAAO,SAAS,CAAC;KACjB;IACD,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC;AACtB,CAAC;AALD,gCAKC"}
\ No newline at end of file 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(); } |