From 5b2cdb8d85437795c672becb6815517705b3562a Mon Sep 17 00:00:00 2001 From: Damien Guard Date: Wed, 7 Nov 2018 22:27:26 -0800 Subject: [PATCH 01/10] Switch to Theia typescript language server --- README.md | 2 +- lib/main.js | 19 ++++++++++++------- package.json | 8 +++++++- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index f455c86..3045556 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # IDE-TypeScript package [![macOS Build Status](https://travis-ci.org/atom/ide-typescript.svg?branch=master)](https://travis-ci.org/atom/ide-typescript) [![Windows Build Status](https://ci.appveyor.com/api/projects/status/o1csvdbqau6m7awm?svg=true)](https://ci.appveyor.com/project/Atom/ide-typescript/branch/master) [![Dependency Status](https://david-dm.org/atom/ide-typescript.svg)](https://david-dm.org/atom/ide-typescript) -TypeScript and JavaScript language support for Atom-IDE, powered by the [Sourcegraph TypeScript Language Server](https://github.com/sourcegraph/javascript-typescript-langserver). +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](https://user-images.githubusercontent.com/118951/30306800-37e3c506-972f-11e7-805c-ba5a45a6bc3c.png) diff --git a/lib/main.js b/lib/main.js index 0ed8baf..c1610af 100644 --- a/lib/main.js +++ b/lib/main.js @@ -14,16 +14,21 @@ class TypeScriptLanguageClient extends AutoLanguageClient { return atom.config.get('ide-typescript.javascriptSupport') ? allScopes : tsScopes } getLanguageName () { return 'TypeScript' } - getServerName () { return 'SourceGraph' } + getServerName () { return 'Theia' } startServerProcess () { this.supportedExtensions = atom.config.get('ide-typescript.javascriptSupport') ? allExtensions : tsExtensions - const args = [ 'node_modules/javascript-typescript-langserver/lib/language-server-stdio' ] - return super.spawnChildNode(args, { cwd: path.join(__dirname, '..') }) + return super.spawnChildNode([ + 'node_modules/typescript-language-server/lib/cli', + '--stdio', + '--tsserver-path', this.getTypescriptServerPath() + ] , { cwd: path.join(__dirname, '..') }) } - preInitialization (connection) { - connection.onCustom('$/partialResult', () => {}) // Suppress partialResult until the language server honors 'streaming' detection + getTypescriptServerPath() { + const tsServerPath = atom.config.get('ide-typescript.typescriptServerPath') + if (tsServerPath) return tsServerPath + return process.platform === 'win32' ? 'tsserver.cmd' : 'tsserver' } consumeLinterV2() { @@ -38,8 +43,8 @@ class TypeScriptLanguageClient extends AutoLanguageClient { shouldStartForEditor(editor) { if (atom.config.get('ide-typescript.ignoreFlow') === true) { - const flowConfigPath = path.join(this.getProjectPath(editor.getURI() || ''), '.flowconfig'); - if (fs.existsSync(flowConfigPath)) return false; + const flowConfigPath = path.join(this.getProjectPath(editor.getURI() || ''), '.flowconfig') + if (fs.existsSync(flowConfigPath)) return false } return super.shouldStartForEditor(editor); } diff --git a/package.json b/package.json index 2241a58..33a737d 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,12 @@ "default": true, "description": "Use the TypeScript language server to provide diagnostics and warnings." }, + "typescriptServerPath": { + "title": "TypeScript tsserver path", + "type": "string", + "default": "", + "description": "Location of the tsserver binary to use in the language server. Defaults to `tsserver` from the current path (`tsserver.cmd` on Windows)." + }, "javascriptSupport": { "type": "boolean", "title": "JavaScript support", @@ -50,7 +56,7 @@ }, "dependencies": { "atom-languageclient": "0.9.7", - "javascript-typescript-langserver": "^2.7.0" + "typescript-language-server": "0.3.6" }, "enhancedScopes": [ "source.ts", From 5c3e704a48e3a05427e96e11412dd783bb23507f Mon Sep 17 00:00:00 2001 From: Damien Guard Date: Thu, 8 Nov 2018 09:21:25 -0800 Subject: [PATCH 02/10] Code formatting supported in Theia language server. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 3045556..5ed2cfd 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ This package is currently an early access release. You should also install the * Go to definition * Hover * Signature help +* Format code ## Contributing Always feel free to help out! Whether it's [filing bugs and feature requests](https://github.com/atom/languageserver-typescript/issues/new) or working on some of the [open issues](https://github.com/atom/languageserver-typescript/issues), Atom's [contributing guide](https://github.com/atom/atom/blob/master/CONTRIBUTING.md) will help get you started while the [guide for contributing to packages](https://github.com/atom/atom/blob/master/docs/contributing-to-packages.md) has some extra information. From 145f71d9d0d62873ad918ceb8798fef20dffd8aa Mon Sep 17 00:00:00 2001 From: Damien Guard Date: Thu, 8 Nov 2018 09:22:12 -0800 Subject: [PATCH 03/10] Switch to MattLyon's fork until upstream supports specifying the node runtime. --- lib/main.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/main.js b/lib/main.js index c1610af..b90b9c7 100644 --- a/lib/main.js +++ b/lib/main.js @@ -19,7 +19,7 @@ class TypeScriptLanguageClient extends AutoLanguageClient { startServerProcess () { this.supportedExtensions = atom.config.get('ide-typescript.javascriptSupport') ? allExtensions : tsExtensions return super.spawnChildNode([ - 'node_modules/typescript-language-server/lib/cli', + 'node_modules/@mattlyons/typescript-language-server/lib/cli', '--stdio', '--tsserver-path', this.getTypescriptServerPath() ] , { cwd: path.join(__dirname, '..') }) diff --git a/package.json b/package.json index 33a737d..6a96281 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ }, "dependencies": { "atom-languageclient": "0.9.7", - "typescript-language-server": "0.3.6" + "@mattlyons/typescript-language-server": "0.4.0" }, "enhancedScopes": [ "source.ts", From 3e1ed5e488924ec0e32ac4de42bfa142e676583c Mon Sep 17 00:00:00 2001 From: Damien Guard Date: Fri, 16 Nov 2018 10:30:22 -0800 Subject: [PATCH 04/10] Work around autocomplete issue in Theia caused by snippet property --- lib/main.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index b90b9c7..5ea493e 100644 --- a/lib/main.js +++ b/lib/main.js @@ -72,8 +72,16 @@ class TypeScriptLanguageClient extends AutoLanguageClient { } onDidConvertAutocomplete(completionItem, suggestion, request) { - if (suggestion.rightLabel == null || suggestion.displayText == null) return + TypeScriptLanguageClient.setLeftAndRightLabels(suggestion) + + // Theia language server sets snippets to '' leading to ambiguity between using that and text + if (suggestion.snippet === '' && suggestion.text != null && suggestion.text !== '') { + suggestion.snippet = undefined + } + } + static setLeftAndRightLabels(suggestion) { + if (suggestion.rightLabel == null || suggestion.displayText == null) return const nameIndex = suggestion.rightLabel.indexOf(suggestion.displayText) if (nameIndex >= 0) { const signature = suggestion.rightLabel.substr(nameIndex + suggestion.displayText.length).trim() @@ -81,8 +89,8 @@ class TypeScriptLanguageClient extends AutoLanguageClient { let paramsEnd = -1 let returnStart = -1 let bracesDepth = 0 - for(let i = 0; i < signature.length; i++) { - switch(signature[i]) { + for (let i = 0; i < signature.length; i++) { + switch (signature[i]) { case '(': { if (bracesDepth++ === 0 && paramsStart === -1) { paramsStart = i; @@ -103,6 +111,7 @@ class TypeScriptLanguageClient extends AutoLanguageClient { } } } + if (atom.config.get('ide-typescript.returnTypeInAutocomplete') === 'left') { if (paramsStart > -1) { suggestion.rightLabel = signature.substring(paramsStart, paramsEnd + 1).trim() From 3ec3ca985322f69dcd8b7288ecb67d31f6fb46df Mon Sep 17 00:00:00 2001 From: Damien Guard Date: Fri, 16 Nov 2018 10:31:51 -0800 Subject: [PATCH 05/10] :arrow_up: atom-languageclient --- package-lock.json | 177 ++++++++++++++++++++++++++++++++++++++++++++++ package.json | 2 +- 2 files changed, 178 insertions(+), 1 deletion(-) create mode 100644 package-lock.json diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..6aa9570 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,177 @@ +{ + "name": "ide-typescript", + "version": "0.7.9", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@types/atom": { + "version": "1.31.0", + "resolved": "https://registry.npmjs.org/@types/atom/-/atom-1.31.0.tgz", + "integrity": "sha512-U0ShGgn9c1jAHK7Q2yv4koof71qr167ODMmRVhsmshFtwEDy758awCLU1oK9hL+3NSYondaHEbgWo7oC/CtUMw==", + "requires": { + "@types/node": "*" + } + }, + "@types/node": { + "version": "8.10.37", + "resolved": "https://registry.npmjs.org/@types/node/-/node-8.10.37.tgz", + "integrity": "sha512-Jp39foY8Euv/PG4OGPyzxis82mnjcUtXLEMA8oFMCE4ilmuJgZPdV2nZNV1moz+99EJTtcpOSgDCgATUwABKig==" + }, + "atom-languageclient": { + "version": "0.9.7", + "resolved": "https://registry.npmjs.org/atom-languageclient/-/atom-languageclient-0.9.7.tgz", + "integrity": "sha512-fpoGSq2hQO5A+2pX6TfcVQnCaP+DcL8Z3maLai6EeGxD1zmFHmBp+QCavr0s941EOw3ZZxrHMY0ab6NQQh9xoA==", + "requires": { + "@types/atom": "^1.28.0", + "@types/node": "^8.0.41", + "fuzzaldrin-plus": "^0.6.0", + "vscode-jsonrpc": "3.6.2", + "vscode-languageserver-protocol": "3.6.0-next.5", + "vscode-languageserver-types": "3.6.1" + }, + "dependencies": { + "vscode-jsonrpc": { + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-3.6.2.tgz", + "integrity": "sha512-T24Jb5V48e4VgYliUXMnZ379ItbrXgOimweKaJshD84z+8q7ZOZjJan0MeDe+Ugb+uqERDVV8SBmemaGMSMugA==" + }, + "vscode-languageserver-protocol": { + "version": "3.6.0-next.5", + "resolved": "http://registry.npmjs.org/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.6.0-next.5.tgz", + "integrity": "sha512-pfu6A4VHDnLn+/UryZc0TKRUl63FdIFMTng27kOER1xk2yXDlqVenQX//8s1Veb0xVGATKITiFKIvUIl037mtg==", + "requires": { + "vscode-jsonrpc": "^3.6.0-next.1", + "vscode-languageserver-types": "^3.6.0-next.1" + } + }, + "vscode-languageserver-types": { + "version": "3.6.1", + "resolved": "http://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.6.1.tgz", + "integrity": "sha512-Npi3i8gUWcx5h8z5idNqPKBLJmZothXK2FSG4csEmxAR7avb8W6l9Ny+VW9yCUB3bOdD7iXfah8IO0AS1jwQmQ==" + } + } + }, + "command-exists": { + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/command-exists/-/command-exists-1.2.6.tgz", + "integrity": "sha512-Qst/zUUNmS/z3WziPxyqjrcz09pm+2Knbs5mAZL4VAE0sSrNY1/w8+/YxeHcoBTsO6iojA6BW7eFf27Eg2MRuw==" + }, + "commander": { + "version": "2.19.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.19.0.tgz", + "integrity": "sha512-6tvAOO+D6OENvRAh524Dh9jcfKTYDQAqvqezbCW82xj5X0pSrcpxtvRKHLG0yBY6SD7PSDrJaj+0AiOcKVd1Xg==" + }, + "crypto-random-string": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/crypto-random-string/-/crypto-random-string-1.0.0.tgz", + "integrity": "sha1-ojD2T1aDEOFJgAmUB5DsmVRbyn4=" + }, + "fs-extra": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-7.0.1.tgz", + "integrity": "sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw==", + "requires": { + "graceful-fs": "^4.1.2", + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" + } + }, + "fuzzaldrin-plus": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/fuzzaldrin-plus/-/fuzzaldrin-plus-0.6.0.tgz", + "integrity": "sha1-gy9kifvodnaUWVmckUpnDsIpR+4=" + }, + "graceful-fs": { + "version": "4.1.15", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.15.tgz", + "integrity": "sha512-6uHUhOPEBgQ24HM+r6b/QwWfZq+yiFcipKFrOFiBEnWdy5sdzYoi+pJeQaPI5qOLRFqWmAXUPQNsielzdLoecA==" + }, + "jsonfile": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", + "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", + "requires": { + "graceful-fs": "^4.1.6" + } + }, + "p-debounce": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/p-debounce/-/p-debounce-1.0.0.tgz", + "integrity": "sha1-y38svu/YegnrqGHhErZ1J+Yh4v0=" + }, + "temp-dir": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/temp-dir/-/temp-dir-1.0.0.tgz", + "integrity": "sha1-CnwOom06Oa+n4OvqnB/AvE2qAR0=" + }, + "tempy": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/tempy/-/tempy-0.2.1.tgz", + "integrity": "sha512-LB83o9bfZGrntdqPuRdanIVCPReam9SOZKW0fOy5I9X3A854GGWi0tjCqoXEk84XIEYBc/x9Hq3EFop/H5wJaw==", + "requires": { + "temp-dir": "^1.0.0", + "unique-string": "^1.0.0" + } + }, + "typescript-language-server": { + "version": "0.3.6", + "resolved": "https://registry.npmjs.org/typescript-language-server/-/typescript-language-server-0.3.6.tgz", + "integrity": "sha512-f+AP/EH9TqBEY43y5wYE3KD/2xouUS/GyJqLC9PYVhEjO2AJgmJw/jpCxM+KrJsKrzzYWqJCiJHdFhGY8yNSDg==", + "requires": { + "command-exists": "1.2.6", + "commander": "^2.11.0", + "fs-extra": "^7.0.0", + "p-debounce": "^1.0.0", + "tempy": "^0.2.1", + "vscode-languageserver": "^4.4.0", + "vscode-uri": "^1.0.5" + } + }, + "unique-string": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unique-string/-/unique-string-1.0.0.tgz", + "integrity": "sha1-nhBXzKhRq7kzmPizOuGHuZyuwRo=", + "requires": { + "crypto-random-string": "^1.0.0" + } + }, + "universalify": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", + "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==" + }, + "vscode-jsonrpc": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-4.0.0.tgz", + "integrity": "sha512-perEnXQdQOJMTDFNv+UF3h1Y0z4iSiaN9jIlb0OqIYgosPCZGYh/MCUlkFtV2668PL69lRDO32hmvL2yiidUYg==" + }, + "vscode-languageserver": { + "version": "4.4.2", + "resolved": "https://registry.npmjs.org/vscode-languageserver/-/vscode-languageserver-4.4.2.tgz", + "integrity": "sha512-61y8Raevi9EigDgg9NelvT9cUAohiEbUl1LOwQQgOCAaNX62yKny/ddi0uC+FUTm4CzsjhBu+06R+vYgfCYReA==", + "requires": { + "vscode-languageserver-protocol": "^3.10.3", + "vscode-uri": "^1.0.5" + } + }, + "vscode-languageserver-protocol": { + "version": "3.13.0", + "resolved": "https://registry.npmjs.org/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.13.0.tgz", + "integrity": "sha512-2ZGKwI+P2ovQll2PGAp+2UfJH+FK9eait86VBUdkPd9HRlm8e58aYT9pV/NYanHOcp3pL6x2yTLVCFMcTer0mg==", + "requires": { + "vscode-jsonrpc": "^4.0.0", + "vscode-languageserver-types": "3.13.0" + } + }, + "vscode-languageserver-types": { + "version": "3.13.0", + "resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.13.0.tgz", + "integrity": "sha512-BnJIxS+5+8UWiNKCP7W3g9FlE7fErFw0ofP5BXJe7c2tl0VeWh+nNHFbwAS2vmVC4a5kYxHBjRy0UeOtziemVA==" + }, + "vscode-uri": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/vscode-uri/-/vscode-uri-1.0.6.tgz", + "integrity": "sha512-sLI2L0uGov3wKVb9EB+vIQBl9tVP90nqRvxSoJ35vI3NjxE8jfsE5DSOhWgSunHSZmKS4OCi2jrtfxK7uyp2ww==" + } + } +} diff --git a/package.json b/package.json index 6a96281..d7ec37a 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ } }, "dependencies": { - "atom-languageclient": "0.9.7", + "atom-languageclient": "0.9.8", "@mattlyons/typescript-language-server": "0.4.0" }, "enhancedScopes": [ From 96a08b20fa6da86642e637884457a58be2a3bb17 Mon Sep 17 00:00:00 2001 From: Damien Guard Date: Mon, 19 Nov 2018 09:44:27 -0800 Subject: [PATCH 06/10] Switch from mattlyons fork of typescript-language-server to upstream --- lib/main.js | 2 +- package-lock.json | 177 ---------------------------------------------- package.json | 2 +- 3 files changed, 2 insertions(+), 179 deletions(-) delete mode 100644 package-lock.json diff --git a/lib/main.js b/lib/main.js index 5ea493e..0b86717 100644 --- a/lib/main.js +++ b/lib/main.js @@ -19,7 +19,7 @@ class TypeScriptLanguageClient extends AutoLanguageClient { startServerProcess () { this.supportedExtensions = atom.config.get('ide-typescript.javascriptSupport') ? allExtensions : tsExtensions return super.spawnChildNode([ - 'node_modules/@mattlyons/typescript-language-server/lib/cli', + 'node_modules/typescript-language-server/lib/cli', '--stdio', '--tsserver-path', this.getTypescriptServerPath() ] , { cwd: path.join(__dirname, '..') }) diff --git a/package-lock.json b/package-lock.json deleted file mode 100644 index 6aa9570..0000000 --- a/package-lock.json +++ /dev/null @@ -1,177 +0,0 @@ -{ - "name": "ide-typescript", - "version": "0.7.9", - "lockfileVersion": 1, - "requires": true, - "dependencies": { - "@types/atom": { - "version": "1.31.0", - "resolved": "https://registry.npmjs.org/@types/atom/-/atom-1.31.0.tgz", - "integrity": "sha512-U0ShGgn9c1jAHK7Q2yv4koof71qr167ODMmRVhsmshFtwEDy758awCLU1oK9hL+3NSYondaHEbgWo7oC/CtUMw==", - "requires": { - "@types/node": "*" - } - }, - "@types/node": { - "version": "8.10.37", - "resolved": "https://registry.npmjs.org/@types/node/-/node-8.10.37.tgz", - "integrity": "sha512-Jp39foY8Euv/PG4OGPyzxis82mnjcUtXLEMA8oFMCE4ilmuJgZPdV2nZNV1moz+99EJTtcpOSgDCgATUwABKig==" - }, - "atom-languageclient": { - "version": "0.9.7", - "resolved": "https://registry.npmjs.org/atom-languageclient/-/atom-languageclient-0.9.7.tgz", - "integrity": "sha512-fpoGSq2hQO5A+2pX6TfcVQnCaP+DcL8Z3maLai6EeGxD1zmFHmBp+QCavr0s941EOw3ZZxrHMY0ab6NQQh9xoA==", - "requires": { - "@types/atom": "^1.28.0", - "@types/node": "^8.0.41", - "fuzzaldrin-plus": "^0.6.0", - "vscode-jsonrpc": "3.6.2", - "vscode-languageserver-protocol": "3.6.0-next.5", - "vscode-languageserver-types": "3.6.1" - }, - "dependencies": { - "vscode-jsonrpc": { - "version": "3.6.2", - "resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-3.6.2.tgz", - "integrity": "sha512-T24Jb5V48e4VgYliUXMnZ379ItbrXgOimweKaJshD84z+8q7ZOZjJan0MeDe+Ugb+uqERDVV8SBmemaGMSMugA==" - }, - "vscode-languageserver-protocol": { - "version": "3.6.0-next.5", - "resolved": "http://registry.npmjs.org/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.6.0-next.5.tgz", - "integrity": "sha512-pfu6A4VHDnLn+/UryZc0TKRUl63FdIFMTng27kOER1xk2yXDlqVenQX//8s1Veb0xVGATKITiFKIvUIl037mtg==", - "requires": { - "vscode-jsonrpc": "^3.6.0-next.1", - "vscode-languageserver-types": "^3.6.0-next.1" - } - }, - "vscode-languageserver-types": { - "version": "3.6.1", - "resolved": "http://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.6.1.tgz", - "integrity": "sha512-Npi3i8gUWcx5h8z5idNqPKBLJmZothXK2FSG4csEmxAR7avb8W6l9Ny+VW9yCUB3bOdD7iXfah8IO0AS1jwQmQ==" - } - } - }, - "command-exists": { - "version": "1.2.6", - "resolved": "https://registry.npmjs.org/command-exists/-/command-exists-1.2.6.tgz", - "integrity": "sha512-Qst/zUUNmS/z3WziPxyqjrcz09pm+2Knbs5mAZL4VAE0sSrNY1/w8+/YxeHcoBTsO6iojA6BW7eFf27Eg2MRuw==" - }, - "commander": { - "version": "2.19.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.19.0.tgz", - "integrity": "sha512-6tvAOO+D6OENvRAh524Dh9jcfKTYDQAqvqezbCW82xj5X0pSrcpxtvRKHLG0yBY6SD7PSDrJaj+0AiOcKVd1Xg==" - }, - "crypto-random-string": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/crypto-random-string/-/crypto-random-string-1.0.0.tgz", - "integrity": "sha1-ojD2T1aDEOFJgAmUB5DsmVRbyn4=" - }, - "fs-extra": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-7.0.1.tgz", - "integrity": "sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw==", - "requires": { - "graceful-fs": "^4.1.2", - "jsonfile": "^4.0.0", - "universalify": "^0.1.0" - } - }, - "fuzzaldrin-plus": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/fuzzaldrin-plus/-/fuzzaldrin-plus-0.6.0.tgz", - "integrity": "sha1-gy9kifvodnaUWVmckUpnDsIpR+4=" - }, - "graceful-fs": { - "version": "4.1.15", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.15.tgz", - "integrity": "sha512-6uHUhOPEBgQ24HM+r6b/QwWfZq+yiFcipKFrOFiBEnWdy5sdzYoi+pJeQaPI5qOLRFqWmAXUPQNsielzdLoecA==" - }, - "jsonfile": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", - "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", - "requires": { - "graceful-fs": "^4.1.6" - } - }, - "p-debounce": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/p-debounce/-/p-debounce-1.0.0.tgz", - "integrity": "sha1-y38svu/YegnrqGHhErZ1J+Yh4v0=" - }, - "temp-dir": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/temp-dir/-/temp-dir-1.0.0.tgz", - "integrity": "sha1-CnwOom06Oa+n4OvqnB/AvE2qAR0=" - }, - "tempy": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/tempy/-/tempy-0.2.1.tgz", - "integrity": "sha512-LB83o9bfZGrntdqPuRdanIVCPReam9SOZKW0fOy5I9X3A854GGWi0tjCqoXEk84XIEYBc/x9Hq3EFop/H5wJaw==", - "requires": { - "temp-dir": "^1.0.0", - "unique-string": "^1.0.0" - } - }, - "typescript-language-server": { - "version": "0.3.6", - "resolved": "https://registry.npmjs.org/typescript-language-server/-/typescript-language-server-0.3.6.tgz", - "integrity": "sha512-f+AP/EH9TqBEY43y5wYE3KD/2xouUS/GyJqLC9PYVhEjO2AJgmJw/jpCxM+KrJsKrzzYWqJCiJHdFhGY8yNSDg==", - "requires": { - "command-exists": "1.2.6", - "commander": "^2.11.0", - "fs-extra": "^7.0.0", - "p-debounce": "^1.0.0", - "tempy": "^0.2.1", - "vscode-languageserver": "^4.4.0", - "vscode-uri": "^1.0.5" - } - }, - "unique-string": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/unique-string/-/unique-string-1.0.0.tgz", - "integrity": "sha1-nhBXzKhRq7kzmPizOuGHuZyuwRo=", - "requires": { - "crypto-random-string": "^1.0.0" - } - }, - "universalify": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", - "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==" - }, - "vscode-jsonrpc": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-4.0.0.tgz", - "integrity": "sha512-perEnXQdQOJMTDFNv+UF3h1Y0z4iSiaN9jIlb0OqIYgosPCZGYh/MCUlkFtV2668PL69lRDO32hmvL2yiidUYg==" - }, - "vscode-languageserver": { - "version": "4.4.2", - "resolved": "https://registry.npmjs.org/vscode-languageserver/-/vscode-languageserver-4.4.2.tgz", - "integrity": "sha512-61y8Raevi9EigDgg9NelvT9cUAohiEbUl1LOwQQgOCAaNX62yKny/ddi0uC+FUTm4CzsjhBu+06R+vYgfCYReA==", - "requires": { - "vscode-languageserver-protocol": "^3.10.3", - "vscode-uri": "^1.0.5" - } - }, - "vscode-languageserver-protocol": { - "version": "3.13.0", - "resolved": "https://registry.npmjs.org/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.13.0.tgz", - "integrity": "sha512-2ZGKwI+P2ovQll2PGAp+2UfJH+FK9eait86VBUdkPd9HRlm8e58aYT9pV/NYanHOcp3pL6x2yTLVCFMcTer0mg==", - "requires": { - "vscode-jsonrpc": "^4.0.0", - "vscode-languageserver-types": "3.13.0" - } - }, - "vscode-languageserver-types": { - "version": "3.13.0", - "resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.13.0.tgz", - "integrity": "sha512-BnJIxS+5+8UWiNKCP7W3g9FlE7fErFw0ofP5BXJe7c2tl0VeWh+nNHFbwAS2vmVC4a5kYxHBjRy0UeOtziemVA==" - }, - "vscode-uri": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/vscode-uri/-/vscode-uri-1.0.6.tgz", - "integrity": "sha512-sLI2L0uGov3wKVb9EB+vIQBl9tVP90nqRvxSoJ35vI3NjxE8jfsE5DSOhWgSunHSZmKS4OCi2jrtfxK7uyp2ww==" - } - } -} diff --git a/package.json b/package.json index d7ec37a..1f682af 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ }, "dependencies": { "atom-languageclient": "0.9.8", - "@mattlyons/typescript-language-server": "0.4.0" + "typescript-language-server": "0.3.7" }, "enhancedScopes": [ "source.ts", From 7dd78548ddc75b32e564355f3f4d903c8a4dc7f2 Mon Sep 17 00:00:00 2001 From: Damien Guard Date: Mon, 19 Nov 2018 11:53:01 -0800 Subject: [PATCH 07/10] Bundle typescript and pass tsserver.js path to theia ls --- lib/main.js | 2 +- package.json | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/main.js b/lib/main.js index 0b86717..a92ed3f 100644 --- a/lib/main.js +++ b/lib/main.js @@ -28,7 +28,7 @@ class TypeScriptLanguageClient extends AutoLanguageClient { getTypescriptServerPath() { const tsServerPath = atom.config.get('ide-typescript.typescriptServerPath') if (tsServerPath) return tsServerPath - return process.platform === 'win32' ? 'tsserver.cmd' : 'tsserver' + return 'node_modules/typescript/lib/tsserver.js' } consumeLinterV2() { diff --git a/package.json b/package.json index 1f682af..2b4a666 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "title": "TypeScript tsserver path", "type": "string", "default": "", - "description": "Location of the tsserver binary to use in the language server. Defaults to `tsserver` from the current path (`tsserver.cmd` on Windows)." + "description": "Location of TypeScript tsserver.js for use by the language server. Defaults to bundled TypeScript dependency." }, "javascriptSupport": { "type": "boolean", @@ -56,6 +56,7 @@ }, "dependencies": { "atom-languageclient": "0.9.8", + "typescript": "~3.1.6", "typescript-language-server": "0.3.7" }, "enhancedScopes": [ From c5300226637af2592a98465bc9afafc103a74061 Mon Sep 17 00:00:00 2001 From: Damien Guard Date: Mon, 19 Nov 2018 12:59:10 -0800 Subject: [PATCH 08/10] Clarify TypeScript server path setting and check at runtime --- lib/main.js | 28 +++++++++++++++++++++------- package.json | 16 +++++++++++----- 2 files changed, 32 insertions(+), 12 deletions(-) diff --git a/lib/main.js b/lib/main.js index a92ed3f..31c3f8a 100644 --- a/lib/main.js +++ b/lib/main.js @@ -21,16 +21,10 @@ class TypeScriptLanguageClient extends AutoLanguageClient { return super.spawnChildNode([ 'node_modules/typescript-language-server/lib/cli', '--stdio', - '--tsserver-path', this.getTypescriptServerPath() + '--tsserver-path', atom.config.get('ide-typescript.typeScriptServer.path') ] , { cwd: path.join(__dirname, '..') }) } - getTypescriptServerPath() { - const tsServerPath = atom.config.get('ide-typescript.typescriptServerPath') - if (tsServerPath) return tsServerPath - return 'node_modules/typescript/lib/tsserver.js' - } - consumeLinterV2() { if (atom.config.get('ide-typescript.diagnosticsEnabled') === true) { super.consumeLinterV2.apply(this, arguments) @@ -46,9 +40,29 @@ class TypeScriptLanguageClient extends AutoLanguageClient { const flowConfigPath = path.join(this.getProjectPath(editor.getURI() || ''), '.flowconfig') if (fs.existsSync(flowConfigPath)) return false } + + if (!this.validateTypeScriptServerPath()) return false + return super.shouldStartForEditor(editor); } + validateTypeScriptServerPath() { + const tsServerPath = atom.config.get('ide-typescript.typeScriptServer.path') + if (fs.existsSync(tsServerPath)) return true + + atom.notifications.addError('ide-typescript could not locate the TypeScript server.', { + dismissable: true, + buttons: [ + { text: 'Set TypeScript server path', onDidClick: () => this.openPackageSettings() }, + ], + description: `No TypeScript server could be found at the specified path of ${tsServerPath}.` + }) + } + + openPackageSettings() { + atom.workspace.open('atom://config/packages/ide-typescript') + } + getProjectPath(filePath) { const projectPath = atom.project.getDirectories().find(d => filePath.startsWith(d.path)) return projectPath != null ? projectPath.path : '' diff --git a/package.json b/package.json index 2b4a666..7b3992c 100644 --- a/package.json +++ b/package.json @@ -14,11 +14,17 @@ "default": true, "description": "Use the TypeScript language server to provide diagnostics and warnings." }, - "typescriptServerPath": { - "title": "TypeScript tsserver path", - "type": "string", - "default": "", - "description": "Location of TypeScript tsserver.js for use by the language server. Defaults to bundled TypeScript dependency." + "typeScriptServer": { + "title": "TypeScript server", + "type": "object", + "properties": { + "path": { + "title": "TypeScript server path", + "type": "string", + "default": "node_modules/typescript/lib/tsserver.js", + "description": "Path to a TypeScript `tsserver.js` the language server. Defaults to the bundled version." + } + } }, "javascriptSupport": { "type": "boolean", From 8e63d22e860aec9e0d99fef6ad8562ebc8beb499 Mon Sep 17 00:00:00 2001 From: Damien Guard Date: Mon, 19 Nov 2018 17:42:33 -0800 Subject: [PATCH 09/10] Prefix unused variables with underscore to make tsc smile --- lib/main.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/main.js b/lib/main.js index 31c3f8a..24e101d 100644 --- a/lib/main.js +++ b/lib/main.js @@ -69,7 +69,7 @@ class TypeScriptLanguageClient extends AutoLanguageClient { } createTimeoutPromise(milliseconds) { - return new Promise((resolve, reject) => { + return new Promise((resolve, _reject) => { let timeout = setTimeout(() => { clearTimeout(timeout) this.logger.error(`Server failed to shutdown in ${milliseconds}ms, forcing termination`) @@ -85,7 +85,7 @@ class TypeScriptLanguageClient extends AutoLanguageClient { return provided } - onDidConvertAutocomplete(completionItem, suggestion, request) { + onDidConvertAutocomplete(_completionItem, suggestion, _request) { TypeScriptLanguageClient.setLeftAndRightLabels(suggestion) // Theia language server sets snippets to '' leading to ambiguity between using that and text From aeba3f3ccb6e2ff8edd10b3fea454169084f0860 Mon Sep 17 00:00:00 2001 From: Damien Guard Date: Mon, 19 Nov 2018 18:24:43 -0800 Subject: [PATCH 10/10] Correct checking relative path of typescript server, clarify setting --- lib/main.js | 12 ++++++++---- package.json | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index 24e101d..9927b04 100644 --- a/lib/main.js +++ b/lib/main.js @@ -47,15 +47,19 @@ class TypeScriptLanguageClient extends AutoLanguageClient { } validateTypeScriptServerPath() { - const tsServerPath = atom.config.get('ide-typescript.typeScriptServer.path') - if (fs.existsSync(tsServerPath)) return true + const tsSpecifiedPath = atom.config.get('ide-typescript.typeScriptServer.path') + const isAbsolutelySpecified = path.isAbsolute(tsSpecifiedPath) + const tsAbsolutePath = isAbsolutelySpecified ? tsSpecifiedPath : path.join(__dirname, '..', tsSpecifiedPath) - atom.notifications.addError('ide-typescript could not locate the TypeScript server.', { + if (fs.existsSync(tsAbsolutePath)) return true + + atom.notifications.addError('ide-typescript could not locate the TypeScript server', { dismissable: true, buttons: [ { text: 'Set TypeScript server path', onDidClick: () => this.openPackageSettings() }, ], - description: `No TypeScript server could be found at the specified path of ${tsServerPath}.` + description: + `No TypeScript server could be found at ${tsAbsolutePath}` }) } diff --git a/package.json b/package.json index 7b3992c..7028a3a 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "title": "TypeScript server path", "type": "string", "default": "node_modules/typescript/lib/tsserver.js", - "description": "Path to a TypeScript `tsserver.js` the language server. Defaults to the bundled version." + "description": "Path to a TypeScript `tsserver.js` the language server will use to process TypeScript. Defaults to the bundled version." } } },