Skip to content

Commit

Permalink
Merge pull request #250 from kiteco/master
Browse files Browse the repository at this point in the history
* adds `kite-installer` to manage `Kite.app` and `kite.js` atom plugin
* adds install page to let user choose between Kite and Jedi
* if user chooses `kite.js`, then he'll be prompted to run `Kite.app` if it isn't running (e.g. shuts down computer and forgets to start it up)
* other than that, there are no other functionality changes
  • Loading branch information
itsdhung committed Dec 1, 2016
2 parents 488e0f3 + b80ef99 commit 39d7389
Show file tree
Hide file tree
Showing 3 changed files with 117 additions and 12 deletions.
89 changes: 87 additions & 2 deletions lib/main.coffee
@@ -1,5 +1,13 @@
window.DEBUG = false
module.exports =
config:
useKite:
type: 'boolean'
default: true
order: 0
title: 'Use Kite-powered Completions'
description: '''Kite is a cloud powered autocomplete engine. It provides
significantly more autocomplete suggestions than the legacy engine.'''
showDescriptions:
type: 'boolean'
default: true
Expand Down Expand Up @@ -108,9 +116,86 @@ module.exports =
suggestions. For example, you can use lower value to give higher priority
for snippets completions which has priority of 2.'''

activate: (state) -> require('./provider').constructor()
installation: null

activate: (state) ->
require('./provider').constructor()

firstInstall = localStorage.getItem('autocomplete-python.installed') == null
localStorage.setItem('autocomplete-python.installed', true)
longRunning = require('process').uptime() > 10
if firstInstall and longRunning
event = "installed"
else if firstInstall
event = "upgraded"
else
event = "restarted"

{
AccountManager,
AtomHelper,
DecisionMaker,
Installation,
Installer,
Metrics,
StateController
} = require 'kite-installer'
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'
dm = new DecisionMaker editorCfg, pluginCfg

checkKiteInstallation = () =>
if not atom.config.get 'autocomplete-python.useKite'
return
canInstall = StateController.canInstallKite()
throttle = dm.shouldOfferKite(event)
Promise.all([throttle, canInstall]).then((values) =>
atom.config.set 'autocomplete-python.useKite', true
variant = values[0]
Metrics.Tracker.name = "atom autocomplete-python install"
Metrics.Tracker.props = variant
@installation = new Installation variant
@installation.accountCreated(() =>
Metrics.Tracker.trackEvent "account created"
atom.config.set 'autocomplete-python.useKite', true
)
@installation.flowSkipped(() =>
Metrics.Tracker.trackEvent "flow aborted"
atom.config.set 'autocomplete-python.useKite', false
)
installer = new Installer()
installer.init @installation.flow
pane = atom.workspace.getActivePane()
@installation.flow.onSkipInstall () =>
atom.config.set 'autocomplete-python.useKite', false
Metrics.Tracker.trackEvent "skipped kite"
pane.destroyActiveItem()
pane.addItem @installation, index: 0
pane.activateItemAtIndex 0
, (err) =>
if err.type == 'denied'
atom.config.set 'autocomplete-python.useKite', false
else
console.log "autocomplete-python ready"
) if atom.config.get 'autocomplete-python.useKite'

checkKiteInstallation()

atom.config.onDidChange 'autocomplete-python.useKite', ({ newValue, oldValue }) =>
if newValue
checkKiteInstallation()
AtomHelper.enablePackage()
else
AtomHelper.disablePackage()

deactivate: -> require('./provider').dispose()
deactivate: ->
require('./provider').dispose()
@installation.destroy() if @installation

getProvider: -> require('./provider')

Expand Down
22 changes: 12 additions & 10 deletions package.json
@@ -1,14 +1,10 @@
{
"name": "autocomplete-python",
"main": "./lib/main",
"version": "1.8.12",
"description": "Python packages, variables, methods and functions with their arguments autocompletion powered by Jedi",
"activationHooks": [
"language-python:grammar-used",
"MagicPython:grammar-used",
"atom-django:grammar-used"
],
"repository": "https://github.com/sadovnychyi/autocomplete-python",
"version": "1.10.8",
"description": "Python completions for packages, variables, methods, functions, with their arguments. Powered by your choice of Jedi or Kite.",
"activationHooks": [],
"repository": "https://github.com/autocomplete-python/autocomplete-python",
"license": "GPL",
"engines": {
"atom": ">=0.194.0 <2.0.0"
Expand All @@ -17,9 +13,11 @@
"atom-slick": "^2.0.0",
"atom-space-pen-views": "~2.1.0",
"fuzzaldrin-plus": "^0.3.1",
"kite-installer": "^0.4.3",
"selector-kit": "^0.1",
"space-pen": "^5.1.2",
"underscore": "^1.8.3"
"underscore": "^1.8.3",
"mixpanel": "^0.5.0"
},
"package-dependencies": {},
"providedServices": {
Expand All @@ -45,10 +43,14 @@
{
"name": "Dmitry Sadovnychyi",
"email": "autocomplete-python@dmit.ro"
},
{
"name": "Daniel Hung",
"email": "daniel@kite.com"
}
],
"bugs": {
"url": "https://github.com/sadovnychyi/autocomplete-python/issues"
"url": "https://github.com/autocomplete-python/autocomplete-python/issues"
},
"keywords": [
"python",
Expand Down
18 changes: 18 additions & 0 deletions styles/autocomplete-python.less
@@ -1,4 +1,5 @@
@import "ui-variables";
@import "../node_modules/kite-installer/styles/styles.less";

atom-text-editor[data-grammar="source python"], :host {
.autocomplete-suggestion-list.select-list.popover-list .suggestion-description-content {
Expand Down Expand Up @@ -33,3 +34,20 @@ autocomplete-python-suggestion {
white-space: pre-wrap;
font-family: @font-family;
}

.install-flow {
.install-flow-step.install-step .row.cta-row .logo {
background-image: url('atom://autocomplete-python/node_modules/kite-installer/styles/logo.png');
}
.welcome-to-kite {
.welcome-title .title-logo {
background-image: url('atom://autocomplete-python/node_modules/kite-installer/styles/smalllogo.png');
}
.description .description-screenshot {
background-image: url('atom://autocomplete-python/node_modules/kite-installer/styles/plotscreenshot.png');
}
}
.install-flow-step.install-step .screenshot {
background-image: url('atom://autocomplete-python/node_modules/kite-installer/styles/screenshot.png');
}
}

0 comments on commit 39d7389

Please sign in to comment.