├── .dockerignore ├── resources ├── outline.png ├── typehint.png ├── autocomplete.gif └── diagnostics.gif ├── .gitignore ├── CODE_OF_CONDUCT.md ├── .circleci └── config.yml ├── .eslintrc.js ├── CONTRIBUTING.md ├── LICENSE ├── PATENTS ├── package.json ├── eslint-rules └── license-header.js ├── README.md └── lib └── main.js /.dockerignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | -------------------------------------------------------------------------------- /resources/outline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebookarchive/ide-flowtype/HEAD/resources/outline.png -------------------------------------------------------------------------------- /resources/typehint.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebookarchive/ide-flowtype/HEAD/resources/typehint.png -------------------------------------------------------------------------------- /resources/autocomplete.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebookarchive/ide-flowtype/HEAD/resources/autocomplete.gif -------------------------------------------------------------------------------- /resources/diagnostics.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebookarchive/ide-flowtype/HEAD/resources/diagnostics.gif -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | yarn.lock 3 | npm-debug.log* 4 | yarn-debug.log* 5 | yarn-error.log* 6 | *~ 7 | .yarn-integrity 8 | 9 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Code of Conduct 2 | 3 | Facebook has adopted a Code of Conduct that we expect project participants to adhere to. 4 | Please read the [full text](https://code.fb.com/codeofconduct/) 5 | so that you can understand what actions will and will not be tolerated. 6 | -------------------------------------------------------------------------------- /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | jobs: 3 | build: 4 | docker: 5 | - image: circleci/node:6 6 | steps: 7 | - checkout 8 | # https://circleci.com/docs/2.0/postgres-config/#postgresql-circleci-configuration-example 9 | - restore_cache: 10 | name: Restore yarn cache 11 | keys: 12 | - myapp-yarn-{{ checksum "yarn.lock" }} 13 | - myapp-yarn- 14 | - run: 15 | name: install 16 | command: yarn 17 | - run: 18 | name: test 19 | command: yarn ci 20 | # https://circleci.com/docs/2.0/postgres-config/#postgresql-circleci-configuration-example 21 | - save_cache: 22 | name: Store yarn cache 23 | key: myapp-yarn-{{ checksum "yarn.lock" }} 24 | paths: 25 | - ~/.yarn-cache 26 | 27 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | * 9 | * @noflow 10 | */ 11 | 'use strict'; 12 | 13 | /* eslint comma-dangle: [1, always-multiline], prefer-object-spread/prefer-object-spread: 0 */ 14 | 15 | const rulesDirPlugin = require('eslint-plugin-rulesdir'); 16 | rulesDirPlugin.RULES_DIR = 'eslint-rules'; 17 | 18 | module.exports = { 19 | extends: 'fbjs-opensource', 20 | plugins: ['rulesdir', 'prettier'], 21 | parserOptions: { 22 | ecmaVersion: 2017, 23 | sourceType: 'script', 24 | }, 25 | rules: { 26 | 'rulesdir/license-header': 1, 27 | }, 28 | }; 29 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to ide-flowtype 2 | We want to make contributing to this project as easy and transparent as 3 | possible. 4 | 5 | ## Pull Requests 6 | We actively welcome your pull requests. 7 | 8 | 1. Fork the repo and create your branch from `master`. 9 | 2. If you've added code that should be tested, add tests. 10 | 3. If you've changed APIs, update the documentation. 11 | 4. Ensure the test suite passes. 12 | 5. Make sure your code lints. 13 | 6. If you haven't already, complete the Contributor License Agreement ("CLA"). 14 | 15 | ## Contributor License Agreement ("CLA") 16 | In order to accept your pull request, we need you to submit a CLA. You only need 17 | to do this once to work on any of Facebook's open source projects. 18 | 19 | Complete your CLA here: 20 | 21 | ## Issues 22 | We use GitHub issues to track public bugs. Please ensure your description is 23 | clear and has sufficient instructions to be able to reproduce the issue. 24 | 25 | Facebook has a [bounty program](https://www.facebook.com/whitehat/) for the safe 26 | disclosure of security bugs. In those cases, please go through the process 27 | outlined on that page and do not file a public issue. 28 | 29 | ## Coding Style 30 | * 2 spaces for indentation rather than tabs 31 | * 80 character line length 32 | * ... 33 | 34 | ## License 35 | By contributing to ide-flowtype, you agree that your contributions will be licensed 36 | under the LICENSE file in the root directory of this source tree. 37 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD License 2 | 3 | For ide-flowtype software 4 | 5 | Copyright (c) 2017-present, Facebook, Inc. All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without modification, 8 | are permitted provided that the following conditions are met: 9 | 10 | * Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | 13 | * Redistributions in binary form must reproduce the above copyright notice, 14 | this list of conditions and the following disclaimer in the documentation 15 | and/or other materials provided with the distribution. 16 | 17 | * Neither the name Facebook nor the names of its contributors may be used to 18 | endorse or promote products derived from this software without specific 19 | prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 25 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 27 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 28 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | -------------------------------------------------------------------------------- /PATENTS: -------------------------------------------------------------------------------- 1 | Additional Grant of Patent Rights Version 2 2 | 3 | "Software" means the ide-flowtype software contributed by Facebook, Inc. 4 | 5 | Facebook, Inc. ("Facebook") hereby grants to each recipient of the Software 6 | ("you") a perpetual, worldwide, royalty-free, non-exclusive, irrevocable 7 | (subject to the termination provision below) license under any Necessary 8 | Claims, to make, have made, use, sell, offer to sell, import, and otherwise 9 | transfer the Software. For avoidance of doubt, no license is granted under 10 | Facebook’s rights in any patent claims that are infringed by (i) modifications 11 | to the Software made by you or any third party or (ii) the Software in 12 | combination with any software or other technology. 13 | 14 | The license granted hereunder will terminate, automatically and without notice, 15 | if you (or any of your subsidiaries, corporate affiliates or agents) initiate 16 | directly or indirectly, or take a direct financial interest in, any Patent 17 | Assertion: (i) against Facebook or any of its subsidiaries or corporate 18 | affiliates, (ii) against any party if such Patent Assertion arises in whole or 19 | in part from any software, technology, product or service of Facebook or any of 20 | its subsidiaries or corporate affiliates, or (iii) against any party relating 21 | to the Software. Notwithstanding the foregoing, if Facebook or any of its 22 | subsidiaries or corporate affiliates files a lawsuit alleging patent 23 | infringement against you in the first instance, and you respond by filing a 24 | patent infringement counterclaim in that lawsuit against that party that is 25 | unrelated to the Software, the license granted hereunder will not terminate 26 | under section (i) of this paragraph due to such counterclaim. 27 | 28 | A "Necessary Claim" is a claim of a patent owned by Facebook that is 29 | necessarily infringed by the Software standing alone. 30 | 31 | A "Patent Assertion" is any lawsuit or other action alleging direct, indirect, 32 | or contributory infringement or inducement to infringe any patent, including a 33 | cross-claim or counterclaim. 34 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ide-flowtype", 3 | "main": "./lib/main", 4 | "license": "BSD-3-Clause", 5 | "repository": "https://github.com/flowtype/ide-flowtype", 6 | "version": "0.24.0", 7 | "description": "Flow-typed JavaScript support for Atom IDE", 8 | "scripts": { 9 | "ci": "yarn lint", 10 | "format": "prettier --write {lib,eslint-rules}/**/*.js .eslintrc.js package.json", 11 | "lint": "eslint lib" 12 | }, 13 | "engines": { 14 | "atom": ">=1.21.0" 15 | }, 16 | "dependencies": { 17 | "atom-languageclient": "0.9.5", 18 | "flow-language-server": "0.5.0" 19 | }, 20 | "activationHooks": [ 21 | "core:loaded-shell-environment" 22 | ], 23 | "enhancedScopes": [ 24 | "source.js", 25 | "source.js.flow", 26 | "source.jsx" 27 | ], 28 | "prettier": { 29 | "bracketSpacing": false, 30 | "proseWrap": "always", 31 | "singleQuote": true, 32 | "trailingComma": "es5" 33 | }, 34 | "consumedServices": { 35 | "status-bar": { 36 | "versions": { 37 | "^1.0.0": "consumeStatusBar" 38 | } 39 | }, 40 | "linter-indie": { 41 | "versions": { 42 | "2.0.0": "consumeLinterV2" 43 | } 44 | }, 45 | "atom-ide-busy-signal": { 46 | "versions": { 47 | "0.1.0": "consumeBusySignal" 48 | } 49 | }, 50 | "datatip": { 51 | "versions": { 52 | "0.1.0": "consumeDatatip" 53 | } 54 | } 55 | }, 56 | "providedServices": { 57 | "autocomplete.provider": { 58 | "versions": { 59 | "2.0.0": "provideAutocomplete" 60 | } 61 | }, 62 | "definitions": { 63 | "versions": { 64 | "0.1.0": "provideDefinitions" 65 | } 66 | }, 67 | "outline-view": { 68 | "versions": { 69 | "0.1.0": "provideOutlines" 70 | } 71 | }, 72 | "hyperclick": { 73 | "versions": { 74 | "0.1.0": "provideHyperclick" 75 | } 76 | } 77 | }, 78 | "devDependencies": { 79 | "eslint": "^v4.6.0", 80 | "eslint-config-fbjs-opensource": "^1.0.0", 81 | "eslint-plugin-prettier": "^2.6.0", 82 | "eslint-plugin-rulesdir": "^0.1.0", 83 | "prettier": "^1.6.1" 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /eslint-rules/license-header.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | * 9 | * @noflow 10 | */ 11 | 'use strict'; 12 | 13 | /* eslint comma-dangle: [1, always-multiline], prefer-object-spread/prefer-object-spread: 0 */ 14 | 15 | const FAKE_DISABLE_RE = /\s*eslint-disable\s+nuclide-internal\/license-header\s*/; 16 | 17 | const SHEBANG_RE = /^#!\/usr\/bin\/env node\n/; 18 | 19 | const FLOW_FORMAT_AND_TRANSPILE = `\ 20 | /** 21 | * Copyright (c) 2017-present, Facebook, Inc. 22 | * All rights reserved. 23 | * 24 | * This source code is licensed under the BSD-style license found in the 25 | * LICENSE file in the root directory of this source tree. An additional grant 26 | * of patent rights can be found in the PATENTS file in the same directory. 27 | * 28 | * @flow 29 | * @format 30 | */ 31 | `; 32 | 33 | const NO_FLOW_AND_NO_TRANSPILE = `\ 34 | /** 35 | * Copyright (c) 2017-present, Facebook, Inc. 36 | * All rights reserved. 37 | * 38 | * This source code is licensed under the BSD-style license found in the 39 | * LICENSE file in the root directory of this source tree. An additional grant 40 | * of patent rights can be found in the PATENTS file in the same directory. 41 | * 42 | * @noflow 43 | */ 44 | 'use strict'; 45 | 46 | /* eslint comma-dangle: [1, always-multiline], prefer-object-spread/prefer-object-spread: 0 */ 47 | `; 48 | 49 | module.exports = function(context) { 50 | // "eslint-disable" disables rules after it. Since the directives have to go 51 | // first, we can't use that mechanism to disable this check. 52 | const comments = context.getAllComments(); 53 | for (let i = 0; i < comments.length; i++) { 54 | if (FAKE_DISABLE_RE.test(comments[i].value)) { 55 | return {}; 56 | } 57 | } 58 | 59 | return { 60 | Program(node) { 61 | const sourceCode = context.getSourceCode(); 62 | const source = sourceCode.text; 63 | 64 | const flowHeader = FLOW_FORMAT_AND_TRANSPILE; 65 | if (source.startsWith(flowHeader)) { 66 | return; 67 | } 68 | 69 | const noFlowHeader = NO_FLOW_AND_NO_TRANSPILE; 70 | if (source.replace(SHEBANG_RE, '').startsWith(noFlowHeader)) { 71 | return; 72 | } 73 | 74 | let fix; 75 | // The modules folder has a special license that shouldn't be blindly applied. 76 | const comment = context.getSourceCode().getAllComments()[0]; 77 | if ( 78 | comment != null && 79 | comment.type === 'Block' && 80 | comment.loc.start.line === 1 81 | ) { 82 | if (comment.value.includes('@flow')) { 83 | fix = fixer => fixer.replaceText(comment, flowHeader.trim()); 84 | } else if (comment.value.includes('@noflow')) { 85 | // TODO: replace the stuff after the docblock. 86 | // It should be pretty obvious to the user, though. 87 | fix = fixer => fixer.replaceText(comment, noFlowHeader.trim()); 88 | } else { 89 | // Default to the @flow header. 90 | fix = fixer => fixer.insertTextBeforeRange([0, 0], flowHeader); 91 | } 92 | } else if (!source.match(SHEBANG_RE)) { 93 | fix = fixer => fixer.insertTextBeforeRange([0, 0], flowHeader); 94 | } 95 | 96 | context.report({ 97 | node, 98 | message: 'Expected a license header', 99 | fix, 100 | }); 101 | }, 102 | }; 103 | }; 104 | 105 | module.exports.schema = []; 106 | module.exports.FLOW_FORMAT_AND_TRANSPILE = FLOW_FORMAT_AND_TRANSPILE; 107 | module.exports.NO_FLOW_AND_NO_TRANSPILE = NO_FLOW_AND_NO_TRANSPILE; 108 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Project Status: 🚨 Unmaintained 🚨 2 | 3 | This project is no longer maintained. We will not be accepting pull requests, addressing issues, nor making future releases. 4 | 5 | The Atom IDE project has been retired and archived. Since this project effectively depends on it, we've made the decision to archive it as well. 6 | 7 | # Flow for Atom IDE (ide-flowtype) 8 | 9 | [Flow-typed JavaScript](https://flow.org/) support for Atom IDE, powered by [the Flow Language Server](https://github.com/flowtype/flow-language-server). 10 | 11 | ![Autocomplete Flow-typed JavaScript](https://raw.githubusercontent.com/flowtype/ide-flowtype/master/resources/autocomplete.gif) 12 | 13 | Extracted from Nuclide, Flow for Atom IDE brings all of the features you need to be productive with Flow-typed JavaScript into Atom. 14 | 15 | ## Installation 16 | 17 | **Notice** Currently, you must also have the `atom-ide-ui` package (the core of Atom IDE) installed in order to take advantage of `ide-flowtype`. We're working with the Atom team to streamline this process. 18 | 19 | Find `ide-flowtype` in the Atom package installer by opening Atom's **Settings**, navigating to **Install**, and searching for `ide-flowtype`. Or maybe you're here inside Atom already. 20 | 21 | If you have Atom's command line utilities, installation is also just a matter of: 22 | `apm install atom-ide-ui && apm install ide-flowtype` 23 | 24 | **Windows is not currently fully supported. This is being actively worked on.** 25 | 26 | ## What is Atom IDE? 27 | 28 | Atom IDE brings the core features you expect in a full-featured IDE into Atom, such as language-aware autocomplete, diagnostics, go-to-definition, type hints, symbol outlines, and more. 29 | 30 | Atom IDE is extracted from [Nuclide](https://nuclide.io/) and is brought to you in partnership by GitHub and Facebook. 31 | 32 | Atom IDE is also a standard protocol within Atom, so you can replace hackable pieces of UI and language integration with your favorites. 33 | 34 | ## Flow for Atom IDE Features 35 | 36 | ### Flow Version Management 37 | 38 | Flow for Atom understands the version of flow you have on your system, as well `flow-bin` in your `package.json` (enable this in settings). 39 | 40 | Otherwise, versions of flow are automatically downloaded, updated, and run transparently. This means you can create a `.flowconfig` for your project and get to work right away. 41 | 42 | ### Autocomplete 43 | 44 | ![Autocomplete Flow-typed JavaScript](https://raw.githubusercontent.com/flowtype/ide-flowtype/master/resources/autocomplete.gif) 45 | 46 | Suggestions directly from the flow server are prioritized in autocomplete. Return types and complex type definitions shown right along suggestions. 47 | 48 | ### Diagnostics 49 | 50 | ![Real-time Diagnostics show errors as you code](https://raw.githubusercontent.com/flowtype/ide-flowtype/master/resources/diagnostics.gif) 51 | 52 | See problems directly in your code the second you hit save. No need to run your code, and no need to flip to your terminal to run `flow`. Instead, Flow for Atom IDE underscores problems as you code. You can even process large sets of problems at once with the bottom diagnostics pane. 53 | 54 | ### Go to Definition 55 | 56 | Want to know how some of your JavaScript works under the hood? Hover over a symbol and hold ⌘ (Mac) or ctrl (Windows and Linux). You'll get a preview of the definition right away, and getting there is only a click away. 57 | 58 | ### Type Hints 59 | 60 | Hover over a symbol and get instant feedback for what you're looking at. Flow even shows you types it can infer without any effort on your part. 61 | 62 | ![Hover for type-hints](https://raw.githubusercontent.com/flowtype/ide-flowtype/master/resources/typehint.png) 63 | 64 | ### Outline 65 | 66 | Get a birds-eye view of your JavaScript with an outline of the document's symbols, and click to jump right where you need to be. 67 | 68 | ![Outline symbols in code](https://raw.githubusercontent.com/flowtype/ide-flowtype/master/resources/outline.png) 69 | 70 | ## Contributing 71 | 72 | ### [Code of Conduct](https://code.facebook.com/codeofconduct) 73 | 74 | Facebook has adopted a Code of Conduct that we expect project participants to adhere to. Please read the full text so that you can understand what actions will and will not be tolerated. 75 | 76 | ### Contributor License Agreement ("CLA") 77 | 78 | In order to accept your pull request, we need you to submit a CLA. You only need 79 | to do this once to work on any of Facebook's open source projects. 80 | 81 | Complete your CLA here: 82 | 83 | ## License 84 | 85 | ide-flowtype is BSD licensed. We also provide an additional patent grant. 86 | -------------------------------------------------------------------------------- /lib/main.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | * 9 | * @noflow 10 | */ 11 | 'use strict'; 12 | 13 | /* eslint comma-dangle: [1, always-multiline], prefer-object-spread/prefer-object-spread: 0 */ 14 | 15 | const {Disposable} = require('atom'); 16 | const {AutoLanguageClient} = require('atom-languageclient'); 17 | const path = require('path'); 18 | const FLOW_DATA_DIR = require('flow-language-server/dirs').flowData; 19 | 20 | const PACKAGE_NAME = require('../package.json').name; 21 | 22 | const SERVER_HOME = path.resolve( 23 | require.resolve('flow-language-server'), 24 | '..', 25 | '..', 26 | 'lib', 27 | 'bin' 28 | ); 29 | 30 | // As defined in the LSP. 31 | const LOG_MESSAGE_INFO = 3; 32 | 33 | // Keep these in sync with the server side. 34 | const STATUS_PREFIX = 'Flow status: '; 35 | const BUSY_STATUS = Object.freeze({ 36 | busy: 'busy', 37 | init: 'initializing', 38 | }); 39 | 40 | // this package's config has the shape: 41 | // type PackageConfig = { 42 | // autoDownloadFlowBinaries: boolean, 43 | // tryFlowBin: boolean, 44 | // customFlowPath: { 45 | // enabled: boolean, 46 | // flowPath: string, 47 | // } 48 | // } 49 | 50 | class FlowLanguageClient extends AutoLanguageClient { 51 | getGrammarScopes() { 52 | return ['source.js', 'source.jsx', 'source.js.jsx', 'source.flow']; 53 | } 54 | 55 | getLanguageName() { 56 | return 'JavaScript'; 57 | } 58 | 59 | getServerName() { 60 | return 'Flow'; 61 | } 62 | 63 | onDidConvertAutocomplete(completionItem, suggestion, request) { 64 | // Flow LSP attaches split values for the parameters and the return type. 65 | // Rather than just using "details", which is a string of both, specify 66 | // each for the left and right labels, according to Atom autocomplete-plus 67 | // convention 68 | if (completionItem._returnDetail) { 69 | suggestion.leftLabel = completionItem._returnDetail; 70 | } 71 | if (completionItem._parametersDetail) { 72 | suggestion.rightLabel = completionItem._parametersDetail; 73 | } 74 | } 75 | 76 | startServerProcess() { 77 | const config = atom.config.get(PACKAGE_NAME); 78 | 79 | const args = ['cli.js', '--stdio']; 80 | if (config.tryFlowBin) { 81 | args.push('--try-flow-bin'); 82 | } 83 | if (config.customFlowPath.enabled && config.customFlowPath.flowPath) { 84 | args.push('--flow-path', config.customFlowPath.flowPath); 85 | } 86 | if (!config.autoDownloadFlowBinaries) { 87 | args.push('--no-auto-download'); 88 | } 89 | 90 | return Promise.resolve(this.spawnChildNode(args, {cwd: SERVER_HOME})); 91 | } 92 | 93 | preInitialization(connection) { 94 | connection.onLogMessage(e => { 95 | if ( 96 | this._busySignalService != null && 97 | e.type === LOG_MESSAGE_INFO && 98 | e.message.startsWith(STATUS_PREFIX) 99 | ) { 100 | if (this._lastBusyMessage) { 101 | this._lastBusyMessage.dispose(); 102 | } 103 | const status = e.message.substr(STATUS_PREFIX.length); 104 | const statusText = BUSY_STATUS[status]; 105 | if (statusText) { 106 | this._lastBusyMessage = this._busySignalService.reportBusy( 107 | `Flow is ${statusText}...` 108 | ); 109 | } 110 | } 111 | }); 112 | connection._rpc.onClose(() => { 113 | if (this._lastBusyMessage) { 114 | this._lastBusyMessage.dispose(); 115 | } 116 | }); 117 | } 118 | 119 | // Have our autocompletion results take priority. 120 | provideAutocomplete() { 121 | const config = atom.config.get(PACKAGE_NAME); 122 | return Object.assign(super.provideAutocomplete(), { 123 | suggestionPriority: config.flowAutocompleteResultsFirst ? 5 : 1, 124 | }); 125 | } 126 | 127 | consumeBusySignal(busySignalService) { 128 | this._busySignalService = busySignalService; 129 | this._disposable.add(busySignalService); 130 | return new Disposable(() => { 131 | this._busySignalService = null; 132 | this._disposable.remove(busySignalService); 133 | }); 134 | } 135 | } 136 | 137 | module.exports = new FlowLanguageClient(); 138 | 139 | module.exports.config = { 140 | tryFlowBin: { 141 | type: 'boolean', 142 | title: 'Use flow-bin from node_modules when available', 143 | description: 144 | 'Use the flow-bin binary from node_modules when present and compatible with ' + 145 | 'the project. Will fall back if version mismatches with your project.\n\n ' + 146 | '**Security Warning:** Atom will execute whichever binary is located at ' + 147 | '$PROJECT_ROOT/node_modules/.bin/flow', 148 | default: false, 149 | order: 10, 150 | }, 151 | autoDownloadFlowBinaries: { 152 | type: 'boolean', 153 | title: 'Automatically download and manage Flow binaries from GitHub', 154 | description: 155 | ` 156 | **Requires an internet connection on first run and when Flow version requirements change.**` + 157 | '\n\n' + 158 | "Atom IDE will detect your project's requirements, and will download and manage flow binaries for you." + 159 | '\n\n' + 160 | `Flow binaries are stored in **${FLOW_DATA_DIR}**`, 161 | default: true, 162 | order: 30, 163 | }, 164 | customFlowPath: { 165 | title: 'Custom Flow executable', 166 | description: 'Use a specific flow executable on your system when running', 167 | type: 'object', 168 | order: 40, 169 | properties: { 170 | enabled: { 171 | type: 'boolean', 172 | default: false, 173 | title: 'Enable custom executable', 174 | order: 10, 175 | }, 176 | flowPath: { 177 | type: 'string', 178 | title: 'Path to Flow executable', 179 | description: 'The path to a specific flow binary', 180 | default: '', 181 | order: 20, 182 | }, 183 | }, 184 | }, 185 | flowAutocompleteResultsFirst: { 186 | type: 'boolean', 187 | title: 'Show Flow autocomplete results first', 188 | description: 189 | 'If checked, Flow suggestions will be placed before the rest of autocomplete results ' + 190 | '(e.g. snippets etc.). Requires restart to take effect.', 191 | default: true, 192 | order: 50, 193 | }, 194 | }; 195 | --------------------------------------------------------------------------------