# Path: sublime_jedi/utils.py
# def to_relative_path(path):
#     """
#     Trim project root pathes from **path** passed as argument
# 
#     If no any folders opened, path will be retuned unchanged
#     """
#     folders = sublime.active_window().folders()
#     for folder in folders:
#         # close path with separator
#         if folder[-1] != os.path.sep:
#             folder += os.path.sep
# 
#         if path.startswith(folder):
#             return path.replace(folder, '')
# 
#     return path
# 
# class PythonCommandMixin(object):
#     """A mixin that hides and disables command for non-python code """
# 
#     def is_visible(self):
#         """ The command is visible only for python code """
#         return is_python_scope(self.view, self.view.sel()[0].begin())
# 
#     def is_enabled(self):
#         """ The command is enabled only when it is visible """
#         return self.is_visible()
# 
# def get_settings(view):
#     """Get plugin settings.
# 
#     :type view: sublime.View
#     :rtype: dict
#     """
#     python_virtualenv = get_settings_param(view, 'python_virtualenv', None)
#     if python_virtualenv:
#         python_virtualenv = expand_path(view, python_virtualenv)
# 
#     python_interpreter = get_settings_param(view, 'python_interpreter', None)
#     if python_interpreter:
#         python_interpreter = expand_path(view, python_interpreter)
# 
#     extra_packages = get_settings_param(view, 'python_package_paths', [])
#     extra_packages = [expand_path(view, p) for p in extra_packages]
# 
#     complete_funcargs = get_settings_param(
#         view, 'auto_complete_function_params', 'all')
# 
#     enable_in_sublime_repl = get_settings_param(
#         view, 'enable_in_sublime_repl', False)
# 
#     sublime_completions_visibility = get_settings_param(
#         view, 'sublime_completions_visibility', 'default')
# 
#     only_complete_after_regex = get_settings_param(
#         view, 'only_complete_after_regex', '')
# 
#     first_folder = ''
#     if view.window().folders():
#         first_folder = os.path.split(view.window().folders()[0])[-1]
#     project_name = get_settings_param(view, 'project_name', first_folder)
# 
#     return {
#         'python_interpreter': python_interpreter,
#         'python_virtualenv': python_virtualenv,
#         'extra_packages': extra_packages,
#         'project_name': project_name,
#         'complete_funcargs': complete_funcargs,
#         'enable_in_sublime_repl': enable_in_sublime_repl,
#         'sublime_completions_visibility': sublime_completions_visibility,
#         'follow_imports': get_settings_param(view, 'follow_imports', True),
#         'completion_timeout': get_settings_param(view, 'comletion_timeout', 3),
#         'only_complete_after_regex': only_complete_after_regex,
#     }
# 
# def is_python_scope(view, location):
#     """ (View, Point) -> bool
# 
#     Get if this is a python source scope (not a string and not a comment)
#     """
#     return view.match_selector(location, "source.python - string - comment")
# 
# def debounce(wait):
#     def decorator(fn):
#         def debounced(*args, **kwargs):
#             def call():
#                 fn(*args, **kwargs)
#             try:
#                 debounced.t.cancel()
#             except AttributeError:
#                 pass
#             debounced.t = Timer(wait, call)
#             debounced.t.start()
#         return debounced
#     return decorator
# 
# Path: sublime_jedi/daemon.py
# def ask_daemon(view, callback, ask_type, ask_kwargs=None, location=None):
#     """Jedi async request shortcut.
# 
#     :type view: sublime.View
#     :type callback: callable
#     :type ask_type: str
#     :type ask_kwargs: dict or None
#     :type location: type of (int, int) or None
#     """
#     window_id = view.window().id()
# 
#     def _async_summon():
#         answer = ask_daemon_sync(view, ask_type, ask_kwargs, location)
#         _run_in_active_view(window_id)(callback)(answer)
# 
#     if callback:
#         sublime.set_timeout_async(_async_summon, 0)


    from typing import Set, List, Tuple, Any
from functools import partial
from .utils import to_relative_path, PythonCommandMixin, get_settings, is_python_scope, debounce
from .daemon import ask_daemon
from .settings import get_settings_param
import sublime
import sublime_plugin
import re

            :param option: list of `jedi.api_classes.BasDefinition`
        """
        active_window = view.window()

        # remember filenames
        self.options = options

        # remember current file location
        self.point = self.view.sel()[0]

        # Show the user a selection of filenames
        active_window.show_quick_panel(
            [self.prepare_option(o) for o in options],
            self._jump_to_in_window,
            on_highlight=partial(self._jump_to_in_window, transient=True))

    def prepare_option(self, option):
        """ prepare option to display out in quick panel """
        raise NotImplementedError(
            "{} require `prepare_option` definition".format(self.__class__)
        )


class SublimeJediGoto(BaseLookUpJediCommand, sublime_plugin.TextCommand):
    """
    Go to object definition
    """
    def run(self, edit):
        follow_imports = get_settings(self.view)['follow_imports']

# Path: sublime_jedi/utils.py
# def to_relative_path(path):
#     """
#     Trim project root pathes from **path** passed as argument
# 
#     If no any folders opened, path will be retuned unchanged
#     """
#     folders = sublime.active_window().folders()
#     for folder in folders:
#         # close path with separator
#         if folder[-1] != os.path.sep:
#             folder += os.path.sep
# 
#         if path.startswith(folder):
#             return path.replace(folder, '')
# 
#     return path
# 
# class PythonCommandMixin(object):
#     """A mixin that hides and disables command for non-python code """
# 
#     def is_visible(self):
#         """ The command is visible only for python code """
#         return is_python_scope(self.view, self.view.sel()[0].begin())
# 
#     def is_enabled(self):
#         """ The command is enabled only when it is visible """
#         return self.is_visible()
# 
# def get_settings(view):
#     """Get plugin settings.
# 
#     :type view: sublime.View
#     :rtype: dict
#     """
#     python_virtualenv = get_settings_param(view, 'python_virtualenv', None)
#     if python_virtualenv:
#         python_virtualenv = expand_path(view, python_virtualenv)
# 
#     python_interpreter = get_settings_param(view, 'python_interpreter', None)
#     if python_interpreter:
#         python_interpreter = expand_path(view, python_interpreter)
# 
#     extra_packages = get_settings_param(view, 'python_package_paths', [])
#     extra_packages = [expand_path(view, p) for p in extra_packages]
# 
#     complete_funcargs = get_settings_param(
#         view, 'auto_complete_function_params', 'all')
# 
#     enable_in_sublime_repl = get_settings_param(
#         view, 'enable_in_sublime_repl', False)
# 
#     sublime_completions_visibility = get_settings_param(
#         view, 'sublime_completions_visibility', 'default')
# 
#     only_complete_after_regex = get_settings_param(
#         view, 'only_complete_after_regex', '')
# 
#     first_folder = ''
#     if view.window().folders():
#         first_folder = os.path.split(view.window().folders()[0])[-1]
#     project_name = get_settings_param(view, 'project_name', first_folder)
# 
#     return {
#         'python_interpreter': python_interpreter,
#         'python_virtualenv': python_virtualenv,
#         'extra_packages': extra_packages,
#         'project_name': project_name,
#         'complete_funcargs': complete_funcargs,
#         'enable_in_sublime_repl': enable_in_sublime_repl,
#         'sublime_completions_visibility': sublime_completions_visibility,
#         'follow_imports': get_settings_param(view, 'follow_imports', True),
#         'completion_timeout': get_settings_param(view, 'comletion_timeout', 3),
#         'only_complete_after_regex': only_complete_after_regex,
#     }
# 
# def is_python_scope(view, location):
#     """ (View, Point) -> bool
# 
#     Get if this is a python source scope (not a string and not a comment)
#     """
#     return view.match_selector(location, "source.python - string - comment")
# 
# def debounce(wait):
#     def decorator(fn):
#         def debounced(*args, **kwargs):
#             def call():
#                 fn(*args, **kwargs)
#             try:
#                 debounced.t.cancel()
#             except AttributeError:
#                 pass
#             debounced.t = Timer(wait, call)
#             debounced.t.start()
#         return debounced
#     return decorator
# 
# Path: sublime_jedi/daemon.py
# def ask_daemon(view, callback, ask_type, ask_kwargs=None, location=None):
#     """Jedi async request shortcut.
# 
#     :type view: sublime.View
#     :type callback: callable
#     :type ask_type: str
#     :type ask_kwargs: dict or None
#     :type location: type of (int, int) or None
#     """
#     window_id = view.window().id()
# 
#     def _async_summon():
#         answer = ask_daemon_sync(view, ask_type, ask_kwargs, location)
#         _run_in_active_view(window_id)(callback)(answer)
# 
#     if callback:
#         sublime.set_timeout_async(_async_summon, 0)


# Path: sublime_jedi/go_to.py
    from typing import Set, List, Tuple, Any
from functools import partial
from .utils import to_relative_path, PythonCommandMixin, get_settings, is_python_scope, debounce
from .daemon import ask_daemon
from .settings import get_settings_param
import sublime
import sublime_plugin
import re


            :param option: list of `jedi.api_classes.BasDefinition`
        """
        active_window = view.window()

        # remember filenames
        self.options = options

        # remember current file location
        self.point = self.view.sel()[0]

        # Show the user a selection of filenames
        active_window.show_quick_panel(
            [self.prepare_option(o) for o in options],
            self._jump_to_in_window,
            on_highlight=partial(self._jump_to_in_window, transient=True))

    def prepare_option(self, option):
        """ prepare option to display out in quick panel """
        raise NotImplementedError(
            "{} require `prepare_option` definition".format(self.__class__)
        )


class SublimeJediGoto(BaseLookUpJediCommand, sublime_plugin.TextCommand):
    """
    Go to object definition
    """
    def run(self, edit):
        follow_imports = get_settings(self.view)['follow_imports']

        ask_daemon(