Skip to content

Commit

Permalink
added Kite integration support
Browse files Browse the repository at this point in the history
  • Loading branch information
DamnWidget committed Mar 16, 2017
1 parent b74794a commit 80162b3
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 0 deletions.
12 changes: 12 additions & 0 deletions AnacondaKite.sublime-settings
@@ -0,0 +1,12 @@
{
/*
Enable this if you use Kite plugin for Sublime Text 3
but you still want to use anaconda functionality.
Note: this option will disable the following anaconda features:
* Autocompletion
* Signature popups
*/
"integrate_with_kite": false
}
6 changes: 6 additions & 0 deletions anaconda_lib/helpers.py
Expand Up @@ -17,6 +17,8 @@

import sublime

from .kite import Integration

# define if we are in a git installation
git_installation = False
try:
Expand Down Expand Up @@ -78,6 +80,10 @@ def completion_is_disabled(view):
if view is None:
return False

# check if Kite integration is enabled
if Integration.enabled():
return True

return get_settings(view, "disable_anaconda_completion", False)


Expand Down
47 changes: 47 additions & 0 deletions anaconda_lib/kite.py
@@ -0,0 +1,47 @@
import sublime


class Integration:
"""Checks if Kite integration is turned on
"""

@classmethod
def enabled(cls):
"""Returns True if Kite integration is enabled
"""

settings = sublime.load_settings('AnacondaKite.sublime-settings')
enabled = settings.get('integrate_with_kite', False)
if enabled:
try:
from Kite.lib.installer import check
from Kite.lib.exceptions import KiteNotSupported
if not check.is_running():
return False
except ImportError:
return False
except KiteNotSupported:
# Kite will raise KiteNotSupported on Linux
return True

return True

return False

@classmethod
def enable(cls):
"""Enable Kite integration
"""

settings = sublime.load_settings('AnacondaKite.sublime-settings')
settings.set('integrate_with_kite', True)
settings.save_settings('AnacondaKite.sublime-settings')

@classmethod
def disable(cls):
"""Disable Kite integration
"""

settings = sublime.load_settings('AnacondaKite.sublime-settings')
settings.set('integrate_with_kite', False)
settings.save_settings('AnacondaKite.sublime-settings')
4 changes: 4 additions & 0 deletions listeners/signatures.py
Expand Up @@ -10,6 +10,7 @@

from ..anaconda_lib.worker import Worker
from ..anaconda_lib.tooltips import Tooltip
from ..anaconda_lib.kite import Integration
from ..anaconda_lib.typing import Dict, Tuple, Any
from ..anaconda_lib.helpers import prepare_send_data, is_python, get_settings

Expand All @@ -35,6 +36,9 @@ def on_modified(self, view: sublime.View) -> None:
if not is_python(view) or not get_settings(view, 'display_signatures'):
return

if Integration.enabled():
return

try:
location = view.rowcol(view.sel()[0].begin())
if view.substr(view.sel()[0].begin()) in ['(', ')']:
Expand Down

0 comments on commit 80162b3

Please sign in to comment.