Skip to content

Commit

Permalink
Add setting to specify Node.js Path
Browse files Browse the repository at this point in the history
This fixes #1
  • Loading branch information
mattlyons0 committed Sep 11, 2018
1 parent 2fa362b commit 713eae1
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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).
Expand Down
21 changes: 16 additions & 5 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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() {
Expand Down
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down

0 comments on commit 713eae1

Please sign in to comment.