From 713eae1766582ff71ab3c5c721ab33ff676727af Mon Sep 17 00:00:00 2001 From: Matt Lyons Date: Tue, 11 Sep 2018 00:53:45 -0400 Subject: [PATCH] Add setting to specify Node.js Path This fixes #1 --- README.md | 4 +++- lib/main.js | 21 ++++++++++++++++----- package.json | 6 ++++++ 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 1557a14..56f3f58 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,11 @@ # IDE-TypeScript-Theia package -TypeScript and JavaScript language support for Atom-IDE, powered by the [Theia TypeScript Language Server](https://github.com/theia-ide/typescript-language-server). +TypeScript and JavaScript language support for Atom-IDE, powered by the [Theia TypeScript Language Server](https://github.com/theia-ide/typescript-language-server) ![Screen shot of IDE-TypeScript](screenshot.png) +### **If outline shows spinner forever you need to specify *Path to Node.js Executable* in Settings** + ## Package Status This package is a fork of [IDE-TypeScript](https://github.com/atom/ide-typescript) which has been modified to use a different Language Server. Since Microsoft's [LSP](https://github.com/Microsoft/language-server-protocol) allows for essentially drop in replacements of servers I created this to resolve some of the [major issues](https://github.com/atom/ide-typescript/issues/113) [SourceGraph's LSP](https://github.com/sourcegraph/javascript-typescript-langserver) has (and their lack of willingness to fix said issues). diff --git a/lib/main.js b/lib/main.js index dd2a249..e48e5cd 100644 --- a/lib/main.js +++ b/lib/main.js @@ -10,6 +10,17 @@ const jsExtensions = [ '.js', '.jsx' ] const allExtensions = tsExtensions.concat(jsExtensions) class TypeScriptLanguageClient extends AutoLanguageClient { + + constructor(){ + super(); + + //Restart server when config is edited + atom.config.observe('ide-typescript-theia.nodePath', () => { + this.deactivate(); + this.activate(); + }); + } + getGrammarScopes () { return atom.config.get('ide-typescript-theia.javascriptSupport') ? allScopes : tsScopes } @@ -19,11 +30,11 @@ class TypeScriptLanguageClient extends AutoLanguageClient { startServerProcess () { this.supportedExtensions = atom.config.get('ide-typescript-theia.javascriptSupport') ? allExtensions : tsExtensions const args = [ 'node_modules/typescript-language-server/lib/cli', '--stdio' ] - return super.spawnChildNode(args, { cwd: path.join(__dirname, '..') }) - } - - preInitialization (connection) { - connection.onCustom('$/partialResult', () => {}) // Suppress partialResult until the language server honors 'streaming' detection + let nodePath = atom.config.get('ide-typescript-theia.nodePath') + let env = Object.create(process.env) + if(nodePath && nodePath.trim() !== '') + env.PATH = nodePath; + return super.spawnChildNode(args, { cwd: path.join(__dirname, '..'), env: env }) } consumeLinterV2() { diff --git a/package.json b/package.json index c3fd0de..150b415 100644 --- a/package.json +++ b/package.json @@ -40,6 +40,12 @@ } ], "description": "Where return types are shown in AutoComplete." + }, + "nodePath": { + "type": "string", + "title": "Path to Node.js Executable", + "default": "", + "description": "If you run into problems with the plugin not starting correctly set this to the directory the 'node' executable is in on your computer (ex: '/usr/local/bin')" } }, "dependencies": {