├── .babelrc ├── .eslintignore ├── .eslintrc ├── .flowconfig ├── .gitignore ├── CHANGELOG.md ├── LICENSE.md ├── README.md ├── declarations └── modules.js ├── package.json └── src ├── helpers.js ├── index.js └── types.js /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["es2015"], 3 | "plugins": ["transform-async-to-generator", "transform-runtime", "transform-flow-strip-types", "transform-object-rest-spread"] 4 | } 5 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | build 2 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "parser": "babel-eslint", 3 | "env": { 4 | "browser": true, 5 | "node": true, 6 | "es6": true 7 | }, 8 | "rules": { 9 | "quotes": [2, "single"], 10 | "eol-last": [0], 11 | "no-underscore-dangle": [0], 12 | "no-cond-assign": 0, 13 | "indent": [2, 2], 14 | "semi": [2, "never"], 15 | "camelcase": 0, 16 | "comma-style": [2, "first"], 17 | "new-cap": 0, 18 | "strict": 0, 19 | "no-unused-expressions": 0, 20 | "semi-spacing": 0, 21 | "consistent-return": 2, 22 | "default-case": 2, 23 | "radix": 2, 24 | "brace-style": 2, 25 | "dot-location": [2, "property"] 26 | }, 27 | "globals": { 28 | "atom": false 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | .*/spec/.* 3 | .*/node_modules/babel.* 4 | .*/node_modules/yargs.* 5 | 6 | [include] 7 | 8 | [libs] 9 | ./declarations/modules.js 10 | 11 | [options] 12 | unsafe.enable_getters_and_setters=true 13 | esproposal.decorators=ignore 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | npm-debug.log 3 | node_modules 4 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 0.1.0 - First Release 2 | * Every feature added 3 | * Every bug fixed 4 | ## 2.0.0 - Complete re-write 5 | * Now a mirror of linter-flow-plus 6 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014 Naman Goel 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # autocomplete-flow 2 | 3 | An autocomplete provider based on flow for awesome javascript development experience in Atom. 4 | 5 | ## Why not nuclide? 6 | 7 | Nuclide is big ide that includes many packages. As such it has many issues. This package does autocomplete powered by flow and nothing else. (see linter-flow for linting help.) 8 | 9 | ## Known Issues 10 | 11 | 1. The package will try to run in every javascript file, even if there isn't a `.flowconfig` file present. 12 | 2. Atom can often fail to find the installed version of flow on your path. If this happens to you, make sure you set the absolute path to the flow executable in the package settings 13 | -------------------------------------------------------------------------------- /declarations/modules.js: -------------------------------------------------------------------------------- 1 | declare class Subscription { 2 | dispose(): void; 3 | } 4 | 5 | declare class Config { 6 | observe(config: string, cb: Function): Subscription; 7 | get(configName: string): string; 8 | } 9 | 10 | declare class Project { 11 | relativizePath(file: string): string; 12 | } 13 | 14 | declare var atom: { 15 | project: Project; 16 | config: Config; 17 | inDevMode(): boolean; 18 | notifications: any; 19 | } 20 | 21 | declare module 'atom' { 22 | declare var Range: any; 23 | declare var CompositeDisposable: any; 24 | declare var config: Config; 25 | } 26 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "autocomplete-flow", 3 | "version": "1.6.0", 4 | "description": "flow powered javascript autocomplete provider for atom", 5 | "activationCommands": [], 6 | "main": "./src/index.js", 7 | "repository": { 8 | "type": "git", 9 | "url": "https://github.com/nmn/autocomplete-flow.git" 10 | }, 11 | "keywords": [ 12 | "linter", 13 | "atom" 14 | ], 15 | "author": "Naman Goel", 16 | "license": "MIT", 17 | "engines": { 18 | "atom": ">0.50.0" 19 | }, 20 | "bugs": { 21 | "url": "https://github.com/nmn/autocomplete-flow/issues" 22 | }, 23 | "homepage": "https://github.com/nmn/autocomplete-flow", 24 | "providedServices": { 25 | "autocomplete.provider": { 26 | "versions": { 27 | "2.0.0": "getCompletionProvider" 28 | } 29 | } 30 | }, 31 | "devDependencies": { 32 | "babel": "^6.5.1", 33 | "babel-cli": "^6.5.1", 34 | "babel-eslint": "^4.1.3", 35 | "babel-plugin-syntax-async-functions": "^6.5.0", 36 | "babel-plugin-transform-async-functions": "^6.5.0", 37 | "babel-plugin-transform-async-to-generator": "^6.5.0", 38 | "babel-plugin-transform-flow-strip-types": "^6.5.0", 39 | "babel-plugin-transform-object-rest-spread": "^6.6.5", 40 | "babel-plugin-transform-runtime": "^6.7.5", 41 | "babel-preset-es2015": "^6.6.0", 42 | "babel-runtime": "^6.6.1", 43 | "eslint": "^1.6.0", 44 | "regenerator": "^0.8.42" 45 | }, 46 | "dependencies": { 47 | "atom-linter": "^4.7.0", 48 | "babel": "^6.5.2", 49 | "babel-cli": "^6.7.5", 50 | "babel-eslint": "^6.0.2", 51 | "babel-plugin-transform-async-to-generator": "^6.7.4", 52 | "babel-plugin-transform-flow-strip-types": "^6.7.0", 53 | "babel-runtime": "^6.5.0", 54 | "fuzzaldrin": "^2.1.0", 55 | "regenerator": "^0.8.41" 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/helpers.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | 'use babel'; 4 | 5 | import cp from 'child_process' 6 | import {exec} from 'atom-linter' 7 | 8 | export function insertAutocompleteToken(contents: string, line: number, col: number): string { 9 | var lines = contents.split('\n') 10 | var theLine = lines[line] 11 | theLine = theLine.substring(0, col) + 'AUTO332' + theLine.substring(col) 12 | lines[line] = theLine 13 | return lines.join('\n') 14 | } 15 | 16 | export function promisedExec(cmdString: string, args: Array, options: Object, file: string): Promise { 17 | return exec(cmdString, args, Object.assign({}, options, {stdin: file})) 18 | .then(JSON.parse) 19 | .then(obj => Array.isArray(obj) ? obj : obj.result) 20 | } 21 | 22 | export function processAutocompleteItem(replacementPrefix: string, flowItem: Object): Object { 23 | var result = 24 | { description: flowItem['type'] 25 | , displayText: flowItem['name'] 26 | , replacementPrefix 27 | } 28 | var funcDetails = flowItem['func_details'] 29 | if (funcDetails) { 30 | // The parameters turned into snippet strings. 31 | var snippetParamStrings = funcDetails['params'] 32 | .map((param, i) => `\${${i + 1}:${param['name']}}`) 33 | // The parameters in human-readable form for use on the right label. 34 | var rightParamStrings = funcDetails['params'] 35 | .map(param => `${param['name']}: ${param['type']}`) 36 | result = 37 | { ...result 38 | , leftLabel: funcDetails['return_type'] 39 | , rightLabel: `(${rightParamStrings.join(', ')})` 40 | , snippet: `${flowItem['name']}(${snippetParamStrings.join(', ')})` 41 | , type: 'function' 42 | } 43 | } else { 44 | result = 45 | { ...result 46 | , rightLabel: flowItem['type'] 47 | , text: flowItem['name'] 48 | } 49 | } 50 | return result 51 | } 52 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | 'use babel'; 4 | 5 | import path from 'path' 6 | import {spawn} from 'child_process' 7 | import {insertAutocompleteToken, promisedExec, processAutocompleteItem} from './helpers' 8 | import {filter} from 'fuzzaldrin' 9 | import { CompositeDisposable } from 'atom' 10 | import {exec, find} from 'atom-linter' 11 | import type {AutocompleteProvider} from './types' 12 | 13 | module.exports = 14 | { config: 15 | { pathToFlowExecutable: 16 | { type: 'string' 17 | , default: 'flow' 18 | } 19 | } 20 | , activate(){ 21 | console.log('activating autocomplete-flow') 22 | 23 | // getting custom value 24 | this.subscriptions = new CompositeDisposable() 25 | this.cmdString = 'flow' 26 | this.subscriptions.add(atom.config.observe('autocomplete-flow.pathToFlowExecutable', (pathToFlow) => { 27 | this.cmdString = pathToFlow || 'flow' 28 | })) 29 | if (atom.inDevMode()) { 30 | console.log('activating... autocomplete-flow') 31 | } 32 | } 33 | , deactivate(){ 34 | if (atom.inDevMode()) { 35 | console.log('deactivating... autocomplete-flow') 36 | } 37 | exec(this.cmdString, ['stop'], {}).catch(() => null) 38 | this.subscriptions.dispose() 39 | } 40 | , getCompletionProvider(): AutocompleteProvider { 41 | const that = this 42 | const provider = 43 | { selector: '.source.js, .source.js.jsx, .source.jsx' 44 | , disableForSelector: '.source.js .comment, source.js .keyword' 45 | , inclusionPriority: 1 46 | , excludeLowerPriority: false 47 | , async getSuggestions({editor, bufferPosition, prefix}){ 48 | if (!prefix) { 49 | return [] 50 | } 51 | const file = editor.getPath() 52 | const currentContents = editor.getText() 53 | const cursor = editor.getLastCursor() 54 | const line = cursor.getBufferRow() 55 | const col = cursor.getBufferColumn() 56 | 57 | const flowConfig = find(file, '.flowconfig') 58 | if (!flowConfig) { 59 | return [] 60 | } 61 | 62 | let options = {} 63 | const args = ['autocomplete', '--json', file] 64 | 65 | // const [cwd] = atom.project.relativizePath(file) 66 | options.cwd = path.dirname(file) //cwd 67 | 68 | try { 69 | const stringWithACToken = insertAutocompleteToken(currentContents, line, col) 70 | const result = await promisedExec(that.cmdString, args, options, stringWithACToken) 71 | if (!result || !result.length) { 72 | return [] 73 | } 74 | // If it is just whitespace and punctuation, ignore it (this keeps us 75 | // from eating leading dots). 76 | const replacementPrefix = /^[\s.]*$/.test(prefix) ? '' : prefix 77 | const candidates = result.map(item => processAutocompleteItem(replacementPrefix, item)) 78 | 79 | // return candidates 80 | return filter(candidates, replacementPrefix, { key: 'displayText' }) 81 | } catch (e) { 82 | const errorM: string = String(e).toLowerCase() 83 | if ( errorM.includes('rechecking') 84 | || errorM.includes('launching') 85 | || errorM.includes('processing') 86 | || errorM.includes('starting') 87 | || errorM.includes('spawned') 88 | || errorM.includes('logs') 89 | || errorM.includes('initializing') 90 | ) { 91 | return [] 92 | } 93 | console.log('[autocomplete-flow] ERROR:', e) 94 | return [] 95 | } 96 | } 97 | } 98 | 99 | return provider 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /src/types.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | 'use babel'; 4 | 5 | export type IPoint = { 6 | row: number; 7 | column: number; 8 | 9 | copy(): IPoint; 10 | freeze(): IPoint; 11 | 12 | translate(delta: IPoint): IPoint; 13 | translate(delta: Array): IPoint; 14 | translate(delta: {row: number, column: number}): IPoint; 15 | 16 | add(other: IPoint): IPoint; 17 | add(other: Array): IPoint; 18 | add(other: {row: number; column: number;}): IPoint; 19 | 20 | splitAt(column: number): Array; 21 | compare(other: IPoint): number; 22 | isEqual(other: IPoint): boolean; 23 | isLessThan(other: IPoint): boolean; 24 | isLessThanOrEqual(other: IPoint): boolean; 25 | isGreaterThan(other: IPoint): boolean; 26 | isGreaterThanOrEqual(other: IPoint): boolean; 27 | toArray(): Array; 28 | serialize(): Array; 29 | } 30 | 31 | export type IRange = { 32 | start: IPoint; 33 | end: IPoint; 34 | serialize(): Array>; 35 | copy(): IRange; 36 | freeze(): IRange; 37 | isEqual(other: IRange): boolean; 38 | isEqual(other: IPoint[]): boolean; 39 | 40 | compare(object: IPoint[]): number; 41 | 42 | compare(object: {start: IPoint; end: IPoint}): number; 43 | compare(object: {start: Array, end: IPoint}): number; 44 | compare(object: {start: {row: number, column: number}, end: IPoint}): number; 45 | 46 | compare(object:{start: IPoint, end: number[]}): number; 47 | compare(object:{start: Array, end: number[]}): number; 48 | compare(object:{start: {row: number, column: number}, end: number[]}): number; 49 | 50 | compare(object:{start: IPoint; end: {row:number; column:number;}}): number; 51 | compare(object:{start: Array, end: {row:number; column:number;}}): number; 52 | compare(object:{start: {row: number, column: number}, end: {row:number, column: number}}): number; 53 | 54 | isSingleLine():boolean; 55 | coversSameRows(other:IRange):boolean; 56 | 57 | add(object:IPoint[]):IRange; 58 | 59 | add(object:{start: IPoint; end: IPoint}):IRange; 60 | add(object:{start: number[]; end: IPoint}):IRange; 61 | add(object:{start: {row:number; column:number;}; end: IPoint}):IRange; 62 | 63 | add(object:{start: IPoint; end: number[]}):IRange; 64 | add(object:{start: number[]; end: number[]}):IRange; 65 | add(object:{start: {row:number; column:number;}; end: number[]}):IRange; 66 | 67 | add(object:{start: IPoint; end: {row:number; column:number;}}):IRange; 68 | add(object:{start: number[]; end: {row:number; column:number;}}):IRange; 69 | add(object:{start: {row:number; column:number;}; end: {row:number; column:number;}}):IRange; 70 | 71 | translate(startPoint:IPoint, endPoint:IPoint):IRange; 72 | translate(startPoint:IPoint):IRange; 73 | 74 | intersectsWith(otherRange:IRange):boolean; 75 | containsRange(otherRange:IRange, exclusive:boolean):boolean; 76 | 77 | containsPoint(point:IPoint, exclusive:boolean):boolean; 78 | containsPoint(point:number[], exclusive:boolean):boolean; 79 | containsPoint(point:{row:number; column:number;}, exclusive:boolean):boolean; 80 | 81 | intersectsRow(row:number):boolean; 82 | intersectsRowRange(startRow:number, endRow:number):boolean; 83 | union(otherRange:IRange):IRange; 84 | isEmpty():boolean; 85 | toDelta():IPoint; 86 | getRowCount():number; 87 | getRows():number[]; 88 | } 89 | 90 | export type TextBuffer = 91 | { cachedText: string 92 | , stoppedChangingDelay: number 93 | , stoppedChangingTimeout: any 94 | , cachedDiskContents: string 95 | , conflict: boolean 96 | , file: any // pathwatcher.IFile 97 | , refcount: number 98 | , lines: Array // 99 | , lineEndings: Array // 100 | , offsetIndex: any // span-skip-list.SpanSkipList 101 | , history: Object 102 | , markers: Object 103 | , loaded: boolean 104 | , digestWhenLastPersisted: string 105 | , modifiedWhenLastPersisted: boolean 106 | , useSerializedText: boolean 107 | 108 | , deserializeParams(params: any): any 109 | , serializeParams(): any 110 | 111 | , getText(): string 112 | , getLines(): string 113 | , isEmpty(): boolean 114 | , getLineCount(): number 115 | , getLastRow(): number 116 | , lineForRow(row: number): string 117 | , getLastLine(): string 118 | , lineEndingForRow(row: number): string 119 | , lineLengthForRow(row: number): number 120 | , setText(text: string): IRange 121 | , setTextViaDiff(text: any): any[] 122 | , setTextInRange(range: IRange, text: string, normalizeLineEndings?: boolean): IRange 123 | , insert(position: IPoint, text: string, normalizeLineEndings?: boolean): IRange 124 | , append(text: string, normalizeLineEndings?: boolean): IRange 125 | , delete(range: IRange): IRange 126 | , deleteRow(row: number): IRange 127 | , deleteRows(startRow: number, endRow: number): IRange 128 | , buildPatch(oldRange: IRange, newText: string, normalizeLineEndings?: boolean): Object 129 | , applyPatch(patch: Object): any 130 | , getTextInRange(range: IRange): string 131 | , clipRange(range: IRange): IRange 132 | , clipPosition(position: IPoint): IPoint 133 | , getFirstPosition(): IPoint 134 | , getEndPosition(): IPoint 135 | , getRange(): IRange 136 | , rangeForRow(row: number, includeNewline?: boolean): IRange 137 | , characterIndexForPosition(position: IPoint): number 138 | , positionForCharacterIndex(offset: number): IPoint 139 | , getMaxCharacterIndex(): number 140 | , loadSync(): TextBuffer 141 | , load(): Promise 142 | , finishLoading(): TextBuffer 143 | , handleTextChange(event: any): any 144 | , destroy(): any 145 | , isAlive(): boolean 146 | , isDestroyed(): boolean 147 | , isRetained(): boolean 148 | , retain(): TextBuffer 149 | , release(): TextBuffer 150 | , subscribeToFile(): any 151 | , hasMultipleEditors(): boolean 152 | , reload(): any 153 | , updateCachedDiskContentsSync(): string 154 | , updateCachedDiskContents(): Promise 155 | , getBaseName(): string 156 | , getPath(): string 157 | , getUri(): string 158 | , setPath(filePath: string): any 159 | , save(): void 160 | , saveAs(filePath: string): any 161 | , isModified(): boolean 162 | , isInConflict(): boolean 163 | , destroyMarker(id: any): any 164 | , matchesInCharacterRange(regex: any, startIndex: any, endIndex: any): any[] 165 | , scan(regex: any, iterator: any): any 166 | , backwardsScan(regex: any, iterator: any): any 167 | , replace(regex: any, replacementText: any): any 168 | , scanInRange(regex: any, range: any, iterator: any, reverse: any): any 169 | , backwardsScanInRange(regex: any, range: any, iterator: any): any 170 | , isRowBlank(row: number): boolean 171 | , previousNonBlankRow(startRow: number): number 172 | , nextNonBlankRow(startRow: number): number 173 | , usesSoftTabs(): boolean 174 | , cancelStoppedChangingTimeout(): any 175 | , scheduleModifiedEvents(): any 176 | , emitModifiedStatusChanged(modifiedStatus: any): any 177 | , logLines(start: number, end: number): void 178 | 179 | // delegate to history property 180 | , undo(): any 181 | , redo(): any 182 | , transact(fn: Function): any 183 | , beginTransaction(): any 184 | , commitTransaction(): any 185 | , abortTransaction(): any 186 | , clearUndoStack(): any 187 | 188 | // delegate to markers property 189 | , markRange(range: any, properties: any): any 190 | , markPosition(range: any, properties: any): any 191 | , getMarker(id: number): Object 192 | , getMarkers(): Array 193 | , getMarkerCount(): number 194 | } 195 | 196 | export type TextEditor = 197 | { deserializing: boolean 198 | , callDisplayBufferCreatedHook: boolean 199 | , registerEditor:boolean 200 | , buffer: TextBuffer 201 | , languageMode: any 202 | , cursors: Array // 203 | , selections: Array // 204 | , suppressSelectionMerging: boolean 205 | , updateBatchDepth: number 206 | , selectionFlashDuration: number 207 | , softTabs: boolean 208 | , displayBuffer: Object 209 | 210 | , id: number 211 | , behaviors: any 212 | , declaredPropertyValues: any 213 | , eventHandlersByEventName: any 214 | , eventHandlersByNamespace: any 215 | , lastOpened: number 216 | , subscriptionCounts: any 217 | , subscriptionsByObject: WeakMap 218 | , subscriptions: Array // 219 | 220 | , mini: any 221 | 222 | , serializeParams(): {id: number, softTabs: boolean, scrollTop: number, scrollLeft: number, displayBuffer: any} 223 | , deserializeParams(params: any): any 224 | , subscribeToBuffer(): void 225 | , subscribeToDisplayBuffer(): void 226 | , getViewClass(): any // return type are EditorView 227 | , destroyed(): void 228 | , isDestroyed(): boolean 229 | , copy(): TextEditor 230 | , getTitle(): string 231 | , getLongTitle(): string 232 | , setVisible(visible: boolean): void 233 | , setMini(mini: any): void 234 | , setScrollTop(scrollTop: any): void 235 | , getScrollTop(): number 236 | , setScrollLeft(scrollLeft: any): void 237 | , getScrollLeft(): number 238 | , setEditorWidthInChars(editorWidthInChars: any): void 239 | , getSoftWrapColumn(): number 240 | , getSoftTabs(): boolean 241 | , setSoftTabs(softTabs: boolean): void 242 | , getSoftWrap(): boolean 243 | , setSoftWrap(softWrap: any): void 244 | , getTabText(): string 245 | , getTabLength(): number 246 | , setTabLength(tabLength: any): void 247 | , usesSoftTabs(): boolean 248 | , clipBufferPosition(bufferPosition: any): void 249 | , clipBufferRange(range: any): void 250 | , indentationForBufferRow(bufferRow: any): void 251 | , setIndentationForBufferRow(bufferRow: any, newLevel: any, _arg: any): void 252 | , indentLevelForLine(line: any): number 253 | , buildIndentString(number: any): string 254 | , save(): void 255 | , saveAs(filePath: any): void 256 | , copyPathToClipboard(): void 257 | , getPath(): string 258 | , getText(): string 259 | , setText(text: any): void 260 | , getTextInRange(range: any): any 261 | , getLineCount(): number 262 | , getBuffer(): TextBuffer 263 | , getURI(): string 264 | , isBufferRowBlank(bufferRow: any): boolean 265 | , isBufferRowCommented(bufferRow: any): void 266 | , nextNonBlankBufferRow(bufferRow: any): void 267 | , getEofBufferPosition(): IPoint 268 | , getLastBufferRow(): number 269 | , bufferRangeForBufferRow(row: any, options: any): IRange 270 | , lineForBufferRow(row: number): string 271 | , lineLengthForBufferRow(row: number): number 272 | , scan(): any 273 | , scanInBufferRange(): any 274 | , backwardsScanInBufferRange(): any 275 | , isModified(): boolean 276 | , isEmpty(): boolean 277 | , shouldPromptToSave(): boolean 278 | , screenPositionForBufferPosition(bufferPosition: any, options?: any): IPoint 279 | , bufferPositionForScreenPosition(screenPosition: any, options?: any): IPoint 280 | , screenRangeForBufferRange(bufferRange:any): IRange 281 | , bufferRangeForScreenRange(screenRange:any): IRange 282 | , clipScreenPosition(screenPosition: any, options: any): IRange 283 | , lineForScreenRow(row: any): Object 284 | , linesForScreenRows(start?: any, end?: any): Array // 285 | , getScreenLineCount(): number 286 | , getMaxScreenLineLength(): number 287 | , getLastScreenRow(): number 288 | , bufferRowsForScreenRows(startRow: any, endRow: any): Array 289 | , bufferRowForScreenRow(row: any): number 290 | , scopesForBufferPosition(bufferPosition: any): Array 291 | , bufferRangeForScopeAtCursor(selector: string): any 292 | , tokenForBufferPosition(bufferPosition: any): Object 293 | , getCursorScopes(): Array 294 | , logCursorScope(): void 295 | , insertText(text: string, options?: any): Array 296 | , insertNewline(): Array 297 | , insertNewlineBelow(): Array 298 | , insertNewlineAbove(): any 299 | , indent(options?: any): any 300 | , backspace(): Array 301 | // deprecated backspaceToBeginningOfWord():any[] 302 | // deprecated backspaceToBeginningOfLine():any[] 303 | , deleteToBeginningOfWord(): Array 304 | , deleteToBeginningOfLine(): Array 305 | , delete(): Array 306 | , deleteToEndOfLine(): Array 307 | , deleteToEndOfWord(): Array 308 | , deleteLine(): Array 309 | , indentSelectedRows(): Array> 310 | , outdentSelectedRows(): Array> 311 | , toggleLineCommentsInSelection(): Array 312 | , autoIndentSelectedRows(): Array> 313 | , normalizeTabsInBufferRange(bufferRange: any): any 314 | , cutToEndOfLine(): boolean[] 315 | , cutSelectedText(): boolean[] 316 | , copySelectedText(): boolean[] 317 | , pasteText(options?: any): Array 318 | , undo(): Array 319 | , redo(): Array 320 | , foldCurrentRow(): any 321 | , unfoldCurrentRow(): Array 322 | , foldSelectedLines(): Array 323 | , foldAll(): Array 324 | , unfoldAll(): Array 325 | , foldAllAtIndentLevel(level: any): any 326 | , foldBufferRow(bufferRow: any): any 327 | , unfoldBufferRow(bufferRow: any): any 328 | , isFoldableAtBufferRow(bufferRow: any): boolean 329 | , isFoldableAtScreenRow(screenRow: any): boolean 330 | , createFold(startRow: any, endRow: any): any 331 | , destroyFoldWithId(id: any): any 332 | , destroyFoldsIntersectingBufferRange(bufferRange: any): any 333 | , toggleFoldAtBufferRow(bufferRow: any): any 334 | , isFoldedAtCursorRow(): boolean 335 | , isFoldedAtBufferRow(bufferRow: any): boolean 336 | , isFoldedAtScreenRow(screenRow: any): boolean 337 | , largestFoldContainingBufferRow(bufferRow: any): boolean 338 | , largestFoldStartingAtScreenRow(screenRow: any): any 339 | , outermostFoldsInBufferRowRange(startRow: any, endRow: any): any[] 340 | , moveLineUp(): Array 341 | , moveLineDown(): Array 342 | , duplicateLines(): Array> 343 | // duprecated duplicateLine():any[][] 344 | , mutateSelectedText(fn: (selection: Object) => any): any 345 | , replaceSelectedText(options:any, fn:(selection:string)=>any):any 346 | , decorationsForScreenRowRange(startScreenRow:any, endScreenRow:any):{[id:number]: Array} 347 | , decorateMarker(marker:any, decorationParams: {type:string, class: string}): any 348 | , decorationForId(id:number):any 349 | , getMarker(id:number):any 350 | , getMarkers(): Array 351 | , findMarkers(...args: Array): Array 352 | , markScreenRange(...args: Array):any 353 | , markBufferRange(...args: Array):any 354 | , markScreenPosition(...args: Array):any 355 | , markBufferPosition(...args: Array):any 356 | , destroyMarker(...args: Array):boolean 357 | , getMarkerCount():number 358 | , hasMultipleCursors():boolean 359 | , getCursors(): Array 360 | , getCursor():any 361 | , addCursorAtScreenPosition(screenPosition:any):any 362 | , addCursorAtBufferPosition(bufferPosition:any):any 363 | , addCursor(marker:any):any 364 | , removeCursor(cursor:any):any[] 365 | , addSelection(marker:any, options:any):any 366 | , addSelectionForBufferRange(bufferRange:any, options:any):any 367 | , setSelectedBufferRange(bufferRange:any, options:any):any 368 | , setSelectedBufferRanges(bufferRanges:any, options:any):any 369 | , removeSelection(selection:any):any 370 | , clearSelections():boolean 371 | , consolidateSelections():boolean 372 | , selectionScreenRangeChanged(selection:any):void 373 | , getSelections():any[] 374 | , getSelection(index?:number): any 375 | , getLastSelection():any 376 | , getSelectionsOrderedByBufferPosition():any[] 377 | , getLastSelectionInBuffer():any 378 | , selectionIntersectsBufferRange(bufferRange:any):any 379 | , setCursorScreenPosition(position: IPoint, options?:any):any 380 | , getCursorScreenPosition(): IPoint 381 | , getCursorScreenRow():number 382 | , setCursorBufferPosition(position:any, options?:any):any 383 | , getCursorBufferPosition(): IPoint 384 | , getSelectedScreenRange():IRange 385 | , getSelectedBufferRange():IRange 386 | , getSelectedBufferRanges():IRange[] 387 | , getSelectedText():string 388 | , getTextInBufferRange(range:IRange):string 389 | , setTextInBufferRange(range:IRange | any[], text:string):any 390 | , getCurrentParagraphBufferRange():IRange 391 | , getWordUnderCursor(options?:any):string 392 | , moveCursorUp(lineCount?:number):void 393 | , moveCursorDown(lineCount?:number):void 394 | , moveCursorLeft():void 395 | , moveCursorRight():void 396 | , moveCursorToTop():void 397 | , moveCursorToBottom():void 398 | , moveCursorToBeginningOfScreenLine():void 399 | , moveCursorToBeginningOfLine():void 400 | , moveCursorToFirstCharacterOfLine():void 401 | , moveCursorToEndOfScreenLine():void 402 | , moveCursorToEndOfLine():void 403 | , moveCursorToBeginningOfWord():void 404 | , moveCursorToEndOfWord():void 405 | , moveCursorToBeginningOfNextWord():void 406 | , moveCursorToPreviousWordBoundary():void 407 | , moveCursorToNextWordBoundary():void 408 | , moveCursorToBeginningOfNextParagraph():void 409 | , moveCursorToBeginningOfPreviousParagraph():void 410 | , scrollToCursorPosition(options:any):any 411 | , pageUp():void 412 | , pageDown():void 413 | , selectPageUp():void 414 | , selectPageDown():void 415 | , getRowsPerPage():number 416 | , moveCursors(fn:(cursor:any)=>any):any 417 | , cursorMoved(event:any):void 418 | , selectToScreenPosition(position: IPoint):any 419 | , selectRight():any[] 420 | , selectLeft():any[] 421 | , selectUp(rowCount?:number):any[] 422 | , selectDown(rowCount?:number):any[] 423 | , selectToTop():any[] 424 | , selectAll():any[] 425 | , selectToBottom():any[] 426 | , selectToBeginningOfLine():any[] 427 | , selectToFirstCharacterOfLine():any[] 428 | , selectToEndOfLine():any[] 429 | , selectToPreviousWordBoundary():any[] 430 | , selectToNextWordBoundary():any[] 431 | , selectLine():any[] 432 | , selectLinesContainingCursors():any[] 433 | , addSelectionBelow():any[] 434 | , addSelectionAbove():any[] 435 | , splitSelectionsIntoLines():any[] 436 | , transpose():IRange[] 437 | , upperCase():boolean[] 438 | , lowerCase():boolean[] 439 | , joinLines():any[] 440 | , selectToBeginningOfWord():any[] 441 | , selectToEndOfWord():any[] 442 | , selectToBeginningOfNextWord():any[] 443 | , selectWord():any[] 444 | , selectToBeginningOfNextParagraph():any[] 445 | , selectToBeginningOfPreviousParagraph():any[] 446 | , selectMarker(marker:any):any 447 | , mergeCursors():number[] 448 | , expandSelectionsForward():any 449 | , expandSelectionsBackward(fn:(selection:any)=>any):any[] 450 | , finalizeSelections():boolean[] 451 | , mergeIntersectingSelections():any 452 | , preserveCursorPositionOnBufferReload():any 453 | , getGrammar(): any 454 | , setGrammar(grammer:any):void 455 | , reloadGrammar():any 456 | , shouldAutoIndent():boolean 457 | , shouldShowInvisibles():boolean 458 | , updateInvisibles():void 459 | , transact(fn:Function):any 460 | , beginTransaction():any 461 | , commitTransaction():any 462 | , abortTransaction():any[] 463 | , inspect():string 464 | , logScreenLines(start:number, end:number):any[] 465 | , handleTokenization():void 466 | , handleGrammarChange():void 467 | , handleMarkerCreated(marker:any):any 468 | , getSelectionMarkerAttributes():{type: string, editorId: number, invalidate: string } 469 | , getVerticalScrollMargin():number 470 | , setVerticalScrollMargin(verticalScrollMargin:number):void 471 | , getHorizontalScrollMargin():number 472 | , setHorizontalScrollMargin(horizontalScrollMargin:number):void 473 | , getLineHeightInPixels():number 474 | , setLineHeightInPixels(lineHeightInPixels:number):void 475 | , batchCharacterMeasurement(fn:Function):void 476 | , getScopedCharWidth(scopeNames:any, char:any):any 477 | , setScopedCharWidth(scopeNames:any, char:any, width:any):any 478 | , getScopedCharWidths(scopeNames:any):any 479 | , clearScopedCharWidths():any 480 | , getDefaultCharWidth():number 481 | , setDefaultCharWidth(defaultCharWidth:number):void 482 | , setHeight(height:number):void 483 | , getHeight():number 484 | , getClientHeight():number 485 | , setWidth(width:number):void 486 | , getWidth():number 487 | , getScrollTop():number 488 | , setScrollTop(scrollTop:number):void 489 | , getScrollBottom():number 490 | , setScrollBottom(scrollBottom:number):void 491 | , getScrollLeft():number 492 | , setScrollLeft(scrollLeft:number):void 493 | , getScrollRight():number 494 | , setScrollRight(scrollRight:number):void 495 | , getScrollHeight():number 496 | , getScrollWidth():number 497 | , getVisibleRowRange():number 498 | , intersectsVisibleRowRange(startRow:any, endRow:any):any 499 | , selectionIntersectsVisibleRowRange(selection:any):any 500 | , pixelPositionForScreenPosition(screenPosition:any):any 501 | , pixelPositionForBufferPosition(bufferPosition:any):any 502 | , screenPositionForPixelPosition(pixelPosition:any):any 503 | , pixelRectForScreenRange(screenRange:any):any 504 | , scrollToScreenRange(screenRange:any, options:any):any 505 | , scrollToScreenPosition(screenPosition:any, options:any):any 506 | , scrollToBufferPosition(bufferPosition:any, options:any):any 507 | , horizontallyScrollable():any 508 | , verticallyScrollable():any 509 | , getHorizontalScrollbarHeight():any 510 | , setHorizontalScrollbarHeight(height:any):any 511 | , getVerticalScrollbarWidth():any 512 | , setVerticalScrollbarWidth(width:any):any 513 | // deprecated joinLine():any 514 | 515 | , onDidChange(callback: Function): any 516 | , onDidDestroy(callback: Function): any 517 | , onDidStopChanging(callback: Function): any 518 | , onDidChangeCursorPosition(callback: Function): any 519 | , onDidSave(callback: (event: { path: string }) => void): any 520 | 521 | , decorateMarker(marker: any, options: any): any 522 | , getLastCursor(): any 523 | } 524 | 525 | export type Suggestion = { 526 | text: string; 527 | displayText?: string; 528 | replacementPrefix?: string; 529 | type? : 'variable' 530 | | 'constant' 531 | | 'property' 532 | | 'value' 533 | | 'method' 534 | | 'function' 535 | | 'class' 536 | | 'type' 537 | | 'keyword' 538 | | 'tag' 539 | | 'snippet' 540 | | 'import' 541 | | 'require'; 542 | leftLabel?: string; 543 | leftLabelHTML?: string; 544 | rightLabel?: string; 545 | rightLabelHTML?: string; 546 | className?: string; 547 | iconHTML?: string; 548 | description?: string; 549 | descriptionMoreURL?: string; 550 | } | { 551 | snippet: string; 552 | displayText?: string; 553 | replacementPrefix?: string; 554 | type? : 'variable' 555 | | 'constant' 556 | | 'property' 557 | | 'value' 558 | | 'method' 559 | | 'function' 560 | | 'class' 561 | | 'type' 562 | | 'keyword' 563 | | 'tag' 564 | | 'snippet' 565 | | 'import' 566 | | 'require'; 567 | leftLabel?: string; 568 | leftLabelHTML?: string; 569 | rightLabel?: string; 570 | rightLabelHTML?: string; 571 | className?: string; 572 | iconHTML?: string; 573 | description?: string; 574 | descriptionMoreURL?: string; 575 | } 576 | 577 | export type AutocompleteProvider = 578 | { selector: '.source.js, .source.js.jsx, .source.jsx' 579 | , disableForSelector: string 580 | , inclusionPriority: 0 | 1 | 2 | 3 | 4 | 5 581 | , excludeLowerPriority: boolean 582 | , getSuggestions(options: {editor: TextEditor, bufferPosition: IPoint, scopeDescriptor: Object, prefix: string}): Array | Promise> 583 | , onDidInsertSuggestion?: (options: {editor: TextEditor, triggerPosition: IPoint, suggestion: any}) => void 584 | , dispose?: Function 585 | } 586 | --------------------------------------------------------------------------------