Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Python packages, variables, methods and functions with their arguments autocompletion in [Atom](http://atom.io) powered by your choice of [Jedi](https://github.com/davidhalter/jedi) or [Kite](https://kite.com).

_Please note that this package is sponsored by Kite and that the Kite code engine is cloud-powered. Type inference on your code is done on Kite's servers._ More info is provided during the install screens of autocomplete-python. __Please read Kite's [privacy policy](https://kite.com/privacy) and [FAQ](http://help.kite.com/category/30-security-privacy) carefully if you have chosen Kite as your completions engine.__
_Please note that this package is sponsored by Kite and that the Kite code engine is cloud-powered. Type inference on your code is done on Kite's servers._ More info is provided during the install screens of autocomplete-python. __Please read Kite's [privacy policy](https://kite.com/privacy) and [FAQ](https://help.kite.com/category/41-security-privacy) carefully if you have chosen Kite as your completions engine.__

See [releases](https://github.com/sadovnychyi/autocomplete-python/releases) for release notes.

Expand Down
73 changes: 35 additions & 38 deletions lib/main.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -152,68 +152,65 @@ module.exports =
{
AccountManager,
AtomHelper,
compatibility,
Installation,
Installer,
Metrics,
Logger,
StateController
StateController,
NodeClient,
install
} = require 'kite-installer'

if atom.config.get('kite.loggingLevel')
Logger.LEVEL = Logger.LEVELS[atom.config.get('kite.loggingLevel').toUpperCase()]

AccountManager.initClient 'alpha.kite.com', -1, true
atom.views.addViewProvider Installation, (m) -> m.element
editorCfg =
UUID: localStorage.getItem('metrics.userId')
name: 'atom'
pluginCfg =
name: 'autocomplete-python'

Metrics.Tracker.name = "atom acp"
Metrics.Tracker.source = 'autocomplete-python'
Metrics.enabled = atom.config.get('core.telemetryConsent') is 'limited'

atom.packages.onDidActivatePackage (pkg) =>
if pkg.name is 'kite'
@patchKiteCompletions(pkg)
Metrics.Tracker.name = "atom kite+acp"

checkKiteInstallation = () =>
if not atom.config.get 'autocomplete-python.useKite'
return
canInstall = StateController.canInstallKite()
compatible = compatibility.check()
Promise.all([compatible, canInstall]).then((values) =>
atom.config.set 'autocomplete-python.useKite', true
variant = {}
Metrics.Tracker.props = variant
Metrics.Tracker.props.lastEvent = event
title = "Choose a autocomplete-python engine"
@installation = new Installation variant, title
@installation.accountCreated(() =>
atom.config.set 'autocomplete-python.useKite', true
return unless atom.config.get 'autocomplete-python.useKite'

StateController.canInstallKite().then(() ->
Install = install.Install
installer = new Install(install.atom().autocompletePythonFlow(), {
path: atom.project.getPaths()[0] || os.homedir(),
}, {
failureStep: 'termination',
title: 'Choose your autocomplete-python engine',
})

initialClient = AccountManager.client
AccountManager.client = new NodeClient('alpha.kite.com', -1, '', true)

atom.workspace.getActivePane().addItem(installer)
atom.workspace.getActivePane().activateItem(installer)

installed = false

installer.onDidDestroy(->
atom.config.set('autocomplete-python.useKite', installed)
AccountManager.client = initialClient
)
@installation.flowSkipped(() =>
atom.config.set 'autocomplete-python.useKite', false

installer.onDidUdpdateState((state) ->
if typeof state.install != 'undefined'
installed = state.install.done || false
)
[projectPath] = atom.project.getPaths()
root = if projectPath? and path.relative(os.homedir(), projectPath).indexOf('..') is 0
path.parse(projectPath).root
else
os.homedir()

installer = new Installer([root])
installer.init @installation.flow, ->
Logger.verbose('in onFinish')
atom.packages.activatePackage('kite')
installer.on('did-skip-install', () ->
installed = false
atom.config.set('autocomplete-python.useKite', installed)
)

pane = atom.workspace.getActivePane()
@installation.flow.onSkipInstall () =>
atom.config.set 'autocomplete-python.useKite', false
pane.destroyActiveItem()
pane.addItem @installation, index: 0
pane.activateItemAtIndex 0
installer.start()
, (err) =>
if typeof err != 'undefined' and err.type == 'denied'
atom.config.set 'autocomplete-python.useKite', false
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"atom-slick": "^2.0.0",
"atom-space-pen-views": "~2.1.0",
"fuzzaldrin-plus": "^0.3.1",
"kite-installer": "^0.23.2",
"kite-installer": "^2.0.5",
"selector-kit": "^0.1",
"space-pen": "^5.1.2",
"underscore": "^1.8.3",
Expand Down