Пример #1
0
    def init_python(self, args):
        self._deoplete = Deoplete(self._vim)
        self._vim.vars['deoplete#_channel_id'] = self._vim.channel_id

        # Check neovim-python version.
        try:
            import pkg_resources
            version = [pkg_resources.get_distribution('neovim').version]
        except Exception:
            # Since neovim-client version 0.1.11
            if hasattr(neovim, 'VERSION'):
                version = [
                    '{major}.{minor}.{patch}{prerelease}'.format(
                        major=neovim.VERSION.major,
                        minor=neovim.VERSION.minor,
                        patch=neovim.VERSION.patch,
                        prerelease=getattr(neovim.VERSION, 'prerelease', ''))
                ]
            else:
                version = []
                python_dir = os.path.dirname(os.path.dirname(neovim.__file__))
                base = python_dir + '/neovim-*/'
                meta_files = glob(base + 'PKG-INFO') + glob(base + '/METADATA')
                for metadata in meta_files:
                    with open(metadata, 'r', errors='replace') as f:
                        for line in f:
                            m = re.match('Version: (.+)', line)
                            if m:
                                version.append(m.group(1))
        self._vim.vars['deoplete#_neovim_python_version'] = version
Пример #2
0
class DeopleteHandlers(object):

    def __init__(self, vim):
        self.__vim = vim

    @neovim.function('_deoplete', sync=True)
    def init_python(self, args):
        self.__deoplete = Deoplete(self.__vim)
        self.__vim.vars['deoplete#_channel_id'] = self.__vim.channel_id

    @neovim.rpc_export('completion_begin')
    def completion_begin(self, context):
        self.__deoplete.completion_begin(context)
Пример #3
0
class DeopleteHandlers(object):

    def __init__(self, vim):
        self.vim = vim

    @neovim.command('DeopleteInitializePython', sync=True, nargs=0)
    def init_python(self):
        self.deoplete = Deoplete(self.vim)
        self.vim.vars['deoplete#_channel_id'] = self.vim.channel_id

    @neovim.rpc_export('completion_begin')
    def completion_begin(self, context):
        self.deoplete.completion_begin(context)
Пример #4
0
    class DeopleteHandlers(object):

        def __init__(self, vim: Nvim):
            self._vim = vim

        @vim.function('_deoplete_init', sync=False)  # type: ignore
        def init_channel(self,
                         args: typing.List[typing.Any]) -> None:
            self._deoplete = Deoplete(self._vim)

        @vim.rpc_export('deoplete_enable_logging')  # type: ignore
        def enable_logging(self, context: Context) -> None:
            self._deoplete.enable_logging()

        @vim.rpc_export('deoplete_auto_completion_begin')  # type: ignore
        def auto_completion_begin(self, context: Context) -> None:
            self._deoplete.completion_begin(context)

        @vim.rpc_export('deoplete_manual_completion_begin')  # type: ignore
        def manual_completion_begin(self, context: Context) -> None:
            self._deoplete.completion_begin(context)

        @vim.rpc_export('deoplete_on_event')  # type: ignore
        def on_event(self, context: Context) -> None:
            self._deoplete.on_event(context)
Пример #5
0
    def init_python(self, args):
        self.__deoplete = Deoplete(self.__vim)
        self.__vim.vars['deoplete#_channel_id'] = self.__vim.channel_id

        # Check neovim-python version.
        version = 'unknown'
        python_dir = os.path.dirname(os.path.dirname(neovim.__file__))
        base = python_dir + '/neovim-*/'
        for metadata in glob(base + 'PKG-INFO') + glob(base + '/METADATA'):
            with open(metadata, 'r', errors='replace') as f:
                for line in f:
                    m = re.match('Version: (.+)', line)
                    if m:
                        version = m.group(1)
        self.__vim.vars['deoplete#_neovim_python_version'] = version
Пример #6
0
class DeopleteHandlers(object):
    def __init__(self, vim):
        self.vim = vim

    @neovim.command("DeopleteInitializePython", sync=True, nargs=0)
    def init_python(self):
        self.deoplete = Deoplete(self.vim)
        self.vim.vars["deoplete#_channel_id"] = self.vim.channel_id

    @neovim.rpc_export("completion_begin")
    def completion_begin(self, context):
        pos = self.vim.current.window.cursor
        try:
            complete_position, candidates = self.deoplete.gather_candidates(context)
        except Exception:
            for line in traceback.format_exc().splitlines():
                error(self.vim, line)
            error(self.vim, "An error has occurred. Please execute :messages command.")
            candidates = []

        if not candidates or self.vim.funcs.mode() != "i" or pos != self.vim.current.window.cursor:
            self.vim.vars["deoplete#_context"] = {}
            return

        var_context = {}
        var_context["complete_position"] = complete_position
        var_context["changedtick"] = context["changedtick"]
        var_context["candidates"] = candidates
        self.vim.vars["deoplete#_context"] = var_context

        # Set (and store) current &completeopt setting.  This cannot be done
        # (currently) from the deoplete_start_complete mapping's function.
        self.vim.command("call deoplete#mappings#_set_completeopt()")
        # Note: cannot use vim.feedkeys()
        self.vim.command('call feedkeys("\<Plug>(deoplete_start_complete)")')
Пример #7
0
class DeopleteHandlers(object):
    def __init__(self, vim):
        self.__vim = vim

    @neovim.function('_deoplete', sync=True)
    def init_python(self, args):
        self.__deoplete = Deoplete(self.__vim)
        self.__vim.vars['deoplete#_channel_id'] = self.__vim.channel_id

    @neovim.rpc_export('deoplete_auto_completion_begin')
    def completion_begin(self, context):
        context['rpc'] = 'deoplete_auto_completion_begin'
        self.__deoplete.completion_begin(context)

    @neovim.rpc_export('deoplete_manual_completion_begin', sync=True)
    def manual_completion_begin(self, context):
        context['rpc'] = 'deoplete_manual_completion_begin'
        self.__deoplete.completion_begin(context)
Пример #8
0
    def init_python(self, args):
        self._deoplete = Deoplete(self._vim)
        self._vim.vars['deoplete#_channel_id'] = self._vim.channel_id

        # Check neovim-python version.
        try:
            import pkg_resources
            version = [pkg_resources.get_distribution('neovim').version]
        except Exception:
            version = []
            python_dir = os.path.dirname(os.path.dirname(neovim.__file__))
            base = python_dir + '/neovim-*/'
            for metadata in glob(base + 'PKG-INFO') + glob(base + '/METADATA'):
                with open(metadata, 'r', errors='replace') as f:
                    for line in f:
                        m = re.match('Version: (.+)', line)
                        if m:
                            version.append(m.group(1))
        self._vim.vars['deoplete#_neovim_python_version'] = version
Пример #9
0
class DeopleteHandlers(object):

    def __init__(self, vim):
        self.__vim = vim

    @neovim.function('_deoplete', sync=True)
    def init_python(self, args):
        self.__deoplete = Deoplete(self.__vim)
        self.__vim.vars['deoplete#_channel_id'] = self.__vim.channel_id

    @neovim.rpc_export('deoplete_enable_logging', sync=True)
    def enable_logging(self, level, logfile):
        logger.setup(self.__vim, level, logfile)
        self.__deoplete.debug_enabled = True

    @neovim.rpc_export('deoplete_auto_completion_begin')
    def completion_begin(self, context):
        context['rpc'] = 'deoplete_auto_completion_begin'
        self.__deoplete.completion_begin(context)

    @neovim.rpc_export('deoplete_manual_completion_begin', sync=True)
    def manual_completion_begin(self, context):
        context['rpc'] = 'deoplete_manual_completion_begin'
        self.__deoplete.completion_begin(context)

    @neovim.rpc_export('deoplete_on_event')
    def on_event(self, context):
        context['rpc'] = 'deoplete_on_event'
        self.__deoplete.on_event(context)
Пример #10
0
class DeopleteHandlers(object):

    def __init__(self, vim):
        self.__vim = vim

    @neovim.function('_deoplete', sync=True)
    def init_python(self, args):
        self.__deoplete = Deoplete(self.__vim)
        self.__vim.vars['deoplete#_channel_id'] = self.__vim.channel_id

    @neovim.rpc_export('deoplete_enable_logging', sync=True)
    def enable_logging(self, level, logfile):
        logger.setup(self.__vim, level, logfile)
        self.__deoplete.debug_enabled = True

    @neovim.rpc_export('deoplete_auto_completion_begin')
    def completion_begin(self, context):
        context['rpc'] = 'deoplete_auto_completion_begin'
        self.__deoplete.completion_begin(context)

    @neovim.rpc_export('deoplete_manual_completion_begin', sync=True)
    def manual_completion_begin(self, context):
        context['rpc'] = 'deoplete_manual_completion_begin'
        self.__deoplete.completion_begin(context)

    @neovim.rpc_export('deoplete_on_buffer')
    def on_buffer(self, context):
        context['rpc'] = 'deoplete_on_buffer'
        self.__deoplete.on_buffer(context)
Пример #11
0
    def init_python(self, args):
        self.__deoplete = Deoplete(self.__vim)
        self.__vim.vars['deoplete#_channel_id'] = self.__vim.channel_id

        # Check neovim-python version.
        version = 'unknown'
        python_dir = os.path.dirname(os.path.dirname(neovim.__file__))
        base = python_dir + '/neovim-*/'
        for metadata in glob(base + 'PKG-INFO') + glob(base + '/METADATA'):
            with open(metadata, 'r', errors='replace') as f:
                for line in f:
                    m = re.match('Version: (.+)', line)
                    if m:
                        version = m.group(1)
        self.__vim.vars['deoplete#_neovim_python_version'] = version
Пример #12
0
class DeopleteHandlers(object):
    def __init__(self, vim):
        self._vim = vim

    @neovim.function('_deoplete', sync=True)
    def init_python(self, args):
        self._deoplete = Deoplete(self._vim)
        self._vim.vars['deoplete#_channel_id'] = self._vim.channel_id

        # Check neovim-python version.
        try:
            import pkg_resources
            version = [pkg_resources.get_distribution('neovim').version]
        except Exception:
            # Since neovim-client version 0.1.11
            if hasattr(neovim, 'VERSION'):
                version = [
                    '{major}.{minor}.{patch}{prerelease}'.format(
                        major=neovim.VERSION.major,
                        minor=neovim.VERSION.minor,
                        patch=neovim.VERSION.patch,
                        prerelease=getattr(neovim.VERSION, 'prerelease', ''))
                ]
            else:
                version = []
                python_dir = os.path.dirname(os.path.dirname(neovim.__file__))
                base = python_dir + '/neovim-*/'
                meta_files = glob(base + 'PKG-INFO') + glob(base + '/METADATA')
                for metadata in meta_files:
                    with open(metadata, 'r', errors='replace') as f:
                        for line in f:
                            m = re.match('Version: (.+)', line)
                            if m:
                                version.append(m.group(1))
        self._vim.vars['deoplete#_neovim_python_version'] = version

    @neovim.rpc_export('deoplete_enable_logging')
    def enable_logging(self, level, logfile):
        logger.setup(self._vim, level, logfile)
        self._deoplete.debug_enabled = True

    @neovim.rpc_export('deoplete_auto_completion_begin')
    def completion_begin(self, context):
        context['rpc'] = 'deoplete_auto_completion_begin'
        self._deoplete.completion_begin(context)

    @neovim.rpc_export('deoplete_manual_completion_begin')
    def manual_completion_begin(self, context):
        context['rpc'] = 'deoplete_manual_completion_begin'
        self._deoplete.completion_begin(context)

    @neovim.rpc_export('deoplete_on_event')
    def on_event(self, context):
        context['rpc'] = 'deoplete_on_event'
        self._deoplete.on_event(context)
Пример #13
0
    def init_python(self, args):
        self._deoplete = Deoplete(self._vim)
        self._vim.vars['deoplete#_channel_id'] = self._vim.channel_id

        # Check neovim-python version.
        try:
            import pkg_resources
            version = [pkg_resources.get_distribution('neovim').version]
        except Exception:
            version = []
            python_dir = os.path.dirname(os.path.dirname(neovim.__file__))
            base = python_dir + '/neovim-*/'
            for metadata in glob(base + 'PKG-INFO') + glob(base + '/METADATA'):
                with open(metadata, 'r', errors='replace') as f:
                    for line in f:
                        m = re.match('Version: (.+)', line)
                        if m:
                            version.append(m.group(1))
        self._vim.vars['deoplete#_neovim_python_version'] = version
Пример #14
0
    class DeopleteHandlers(object):
        def __init__(self, vim):
            self._vim = vim

        @neovim.function('_deoplete_init', sync=False)
        def init_channel(self, args):
            self._deoplete = Deoplete(self._vim)

        @neovim.rpc_export('deoplete_enable_logging')
        def enable_logging(self, context):
            self._deoplete.enable_logging()

        @neovim.rpc_export('deoplete_auto_completion_begin')
        def auto_completion_begin(self, context):
            self._deoplete.completion_begin(context)

        @neovim.rpc_export('deoplete_manual_completion_begin')
        def manual_completion_begin(self, context):
            self._deoplete.completion_begin(context)

        @neovim.rpc_export('deoplete_on_event')
        def on_event(self, context):
            self._deoplete.on_event(context)
Пример #15
0
    class DeopleteHandlers(object):

        def __init__(self, vim):
            self._vim = vim

        @neovim.function('_deoplete_init', sync=False)
        def init_channel(self, args):
            self._deoplete = Deoplete(self._vim)

        @neovim.rpc_export('deoplete_enable_logging')
        def enable_logging(self, context):
            self._deoplete.enable_logging()

        @neovim.rpc_export('deoplete_auto_completion_begin')
        def auto_completion_begin(self, context):
            self._deoplete.completion_begin(context)

        @neovim.rpc_export('deoplete_manual_completion_begin')
        def manual_completion_begin(self, context):
            self._deoplete.completion_begin(context)

        @neovim.rpc_export('deoplete_on_event')
        def on_event(self, context):
            self._deoplete.on_event(context)
Пример #16
0
class DeopleteHandlers(object):
    def __init__(self, vim):
        self.vim = vim

    @neovim.command('DeopleteInitializePython', sync=True, nargs=0)
    def init_python(self):
        self.deoplete = Deoplete(self.vim)
        self.vim.vars['deoplete#_channel_id'] = self.vim.channel_id

    @neovim.rpc_export('completion_begin')
    def completion_begin(self, context):
        pos = self.vim.current.window.cursor
        try:
            complete_position, candidates = self.deoplete.gather_candidates(
                context)
        except Exception:
            for line in traceback.format_exc().splitlines():
                error(self.vim, line)
            error(self.vim,
                  'An error has occurred. Please execute :messages command.')
            candidates = []

        if not candidates or self.vim.funcs.mode() != 'i' \
                or pos != self.vim.current.window.cursor:
            self.vim.vars['deoplete#_context'] = {}
            return

        var_context = {}
        var_context['complete_position'] = complete_position
        var_context['changedtick'] = context['changedtick']
        var_context['candidates'] = candidates
        self.vim.vars['deoplete#_context'] = var_context

        # Set (and store) current &completeopt setting.  This cannot be done
        # (currently) from the deoplete_start_complete mapping's function.
        self.vim.call('deoplete#mappings#_set_completeopt')
        # Note: cannot use vim.feedkeys()
        self.vim.command('call feedkeys("\<Plug>(deoplete_start_complete)")')
Пример #17
0
class DeopleteHandlers(object):

    def __init__(self, vim):
        self._vim = vim

    @neovim.function('_deoplete', sync=True)
    def init_python(self, args):
        self._deoplete = Deoplete(self._vim)
        self._vim.vars['deoplete#_channel_id'] = self._vim.channel_id

        # Check neovim-python version.
        try:
            import pkg_resources
            version = [pkg_resources.get_distribution('neovim').version]
        except Exception:
            version = []
            python_dir = os.path.dirname(os.path.dirname(neovim.__file__))
            base = python_dir + '/neovim-*/'
            for metadata in glob(base + 'PKG-INFO') + glob(base + '/METADATA'):
                with open(metadata, 'r', errors='replace') as f:
                    for line in f:
                        m = re.match('Version: (.+)', line)
                        if m:
                            version.append(m.group(1))
        self._vim.vars['deoplete#_neovim_python_version'] = version

    @neovim.rpc_export('deoplete_enable_logging')
    def enable_logging(self, level, logfile):
        logger.setup(self._vim, level, logfile)
        self._deoplete.debug_enabled = True

    @neovim.rpc_export('deoplete_auto_completion_begin')
    def completion_begin(self, context):
        context['rpc'] = 'deoplete_auto_completion_begin'
        self._deoplete.completion_begin(context)

    @neovim.rpc_export('deoplete_manual_completion_begin')
    def manual_completion_begin(self, context):
        context['rpc'] = 'deoplete_manual_completion_begin'
        self._deoplete.completion_begin(context)

    @neovim.rpc_export('deoplete_on_event')
    def on_event(self, context):
        context['rpc'] = 'deoplete_on_event'
        self._deoplete.on_event(context)
Пример #18
0
class DeopleteHandlers(object):
    def __init__(self, vim):
        self.__vim = vim

    @neovim.function('_deoplete', sync=True)
    def init_python(self, args):
        self.__deoplete = Deoplete(self.__vim)
        self.__vim.vars['deoplete#_channel_id'] = self.__vim.channel_id

        # Check neovim-python version.
        try:
            import pkg_resources
            version = [pkg_resources.get_distribution('neovim').version]
        except Exception:
            version = []
            python_dir = os.path.dirname(os.path.dirname(neovim.__file__))
            base = python_dir + '/neovim-*/'
            for metadata in glob(base + 'PKG-INFO') + glob(base + '/METADATA'):
                with open(metadata, 'r', errors='replace') as f:
                    for line in f:
                        m = re.match('Version: (.+)', line)
                        if m:
                            version.append(m.group(1))
        self.__vim.vars['deoplete#_neovim_python_version'] = version

    @neovim.rpc_export('deoplete_enable_logging', sync=True)
    def enable_logging(self, level, logfile):
        logger.setup(self.__vim, level, logfile)
        self.__deoplete.debug_enabled = True

    @neovim.rpc_export('deoplete_auto_completion_begin')
    def completion_begin(self, context):
        context['rpc'] = 'deoplete_auto_completion_begin'
        self.__deoplete.completion_begin(context)

    @neovim.rpc_export('deoplete_manual_completion_begin', sync=True)
    def manual_completion_begin(self, context):
        context['rpc'] = 'deoplete_manual_completion_begin'
        self.__deoplete.completion_begin(context)

    @neovim.rpc_export('deoplete_on_event')
    def on_event(self, context):
        context['rpc'] = 'deoplete_on_event'
        self.__deoplete.on_event(context)
Пример #19
0
 def init_python(self, args):
     self.__deoplete = Deoplete(self.__vim)
     self.__vim.vars['deoplete#_channel_id'] = self.__vim.channel_id
Пример #20
0
 def init_channel(self, args: typing.List[typing.Any]) -> None:
     self._deoplete = Deoplete(self._vim)
     self._vim.call('deoplete#send_event', 'BufReadPost')
Пример #21
0
        @vim.rpc_export('deoplete_auto_completion_begin')  # type: ignore
        def auto_completion_begin(self, context: Context) -> None:
            self._deoplete.completion_begin(context)

        @vim.rpc_export('deoplete_manual_completion_begin')  # type: ignore
        def manual_completion_begin(self, context: Context) -> None:
            self._deoplete.completion_begin(context)

        @vim.rpc_export('deoplete_on_event')  # type: ignore
        def on_event(self, context: Context) -> None:
            self._deoplete.on_event(context)


if find_spec('yarp'):

    global_deoplete = Deoplete(vim)

    def deoplete_init() -> None:
        global_deoplete._vim.call('deoplete#send_event', 'BufReadPost')

    def deoplete_enable_logging(context: Context) -> None:
        global_deoplete.enable_logging()

    def deoplete_auto_completion_begin(context: Context) -> None:
        global_deoplete.completion_begin(context)

    def deoplete_manual_completion_begin(context: Context) -> None:
        global_deoplete.completion_begin(context)

    def deoplete_on_event(context: Context) -> None:
        global_deoplete.on_event(context)
Пример #22
0
 def init_channel(self,
                  args: typing.List[typing.Any]) -> None:
     self._deoplete = Deoplete(self._vim)
Пример #23
0
 def init_python(self):
     self.deoplete = Deoplete(self.vim)
     self.vim.vars['deoplete#_channel_id'] = self.vim.channel_id
Пример #24
0
 def init_python(self):
     self.deoplete = Deoplete(self.vim)
     self.vim.vars['deoplete#_channel_id'] = self.vim.channel_id
Пример #25
0
 def init_python(self):
     self.deoplete = Deoplete(self.vim)
     self.vim.command('let g:deoplete#_channel_id = '
     + str(self.vim.channel_id))
Пример #26
0
class DeopleteHandlers(object):
    def __init__(self, vim):
        self.vim = vim
        self.msgfile = self.vim.eval('tempname()')

    def debug(self, msg):
        self.vim.command('echomsg string("' + str(msg) + '")')

    def error(self, e):
        with open(self.msgfile, 'a') as f:
            traceback.print_exc(None, f)
        self.vim.command('call deoplete#util#print_error('
                         + '"The error is occurred.  Please read ".'
                         + 'string("'+self.msgfile+'").'
                         +'" file or execute :DeopleteMessages command.")')

    @neovim.command('DeopleteInitializePython', sync=True, nargs=0)
    def init_python(self):
        self.deoplete = Deoplete(self.vim)
        self.vim.command('let g:deoplete#_channel_id = '
        + str(self.vim.channel_id))

    @neovim.command('DeopleteMessages', sync=True, nargs=0)
    def print_error(self):
        self.vim.command('edit ' + self.msgfile)

    @neovim.rpc_export('completion_begin')
    def completion_begin(self, context):
        # Skip
        if self.vim.eval('g:deoplete#_skip_next_complete'):
            self.vim.command(
                'let g:deoplete#_skip_next_complete = 0')
            return
        if self.vim.eval('&paste') != 0:
            return

        # Call omni completion
        omni_patterns = deoplete.util.convert2list(
            deoplete.util.get_buffer_config(
                self.vim, context,
                'b:deoplete_omni_patterns',
                'g:deoplete#omni_patterns',
                'g:deoplete#_omni_patterns'))
        # self.debug(omni_pattern)
        for pattern in omni_patterns:
            if self.vim.eval('mode()') == 'i' \
                    and (pattern != '' \
                         and self.vim.eval('&l:omnifunc') != '' \
                         and re.search('('+pattern+')$', context['input'])) \
                         or self.vim.eval(
                             'deoplete#util#is_eskk_convertion()') != 0:
                self.vim.command(
                    'call feedkeys("\<C-x>\<C-o>", "n")')
                return

        try:
            complete_position, candidates = \
                self.deoplete.gather_candidates(context)
        except Exception as e:
            self.error(e)
            candidates = []
        if not candidates or self.vim.eval('mode()') != 'i':
                return
        self.vim.command(
          'let g:deoplete#_context = {}')
        self.vim.command(
          'let g:deoplete#_context.complete_position = '
            + str(complete_position))
        self.vim.command(
          'let g:deoplete#_context.changedtick = '
            + str(context['changedtick']))
        self.vim.command(
          'let g:deoplete#_context.candidates = '
            + str(candidates))
        self.vim.command(
          'call feedkeys("\<Plug>(deoplete_start_complete)")')
Пример #27
0
 def init_channel(self, args):
     self._deoplete = Deoplete(self._vim)
Пример #28
0
 def init_python(self, args):
     self.__deoplete = Deoplete(self.__vim)
     self.__vim.vars['deoplete#_channel_id'] = self.__vim.channel_id
Пример #29
0
class DeopleteHandlers(object):
    def __init__(self, vim):
        self.vim = vim

    def debug(self, msg):
        self.vim.command('echomsg string("' + str(msg) + '")')

    def error(self, e):
        tmp = self.vim.eval('tempname()')
        with open(tmp, 'w') as f:
            traceback.print_exc(None, f)
        self.vim.command('call deoplete#util#print_error(' \
                         + '"The error is occurred.  Please read ".'
                         + 'string("'+tmp+'")." file.")')

    @neovim.command('DeopleteInitializePython', sync=True, nargs=0)
    def init_python(self):
        self.deoplete = Deoplete(self.vim)
        self.vim.command('let g:deoplete#_channel_id = '
        + str(self.vim.channel_id))

    @neovim.rpc_export('completion_begin')
    def completion_begin(self, context):
        # Encoding conversion
        encoding = self.vim.eval('&encoding')
        context = { k.decode(encoding) :
                    (v.decode(encoding) if isinstance(v, bytes) else v)
                    for k, v in context.items()}

        # Call omni completion
        omni_patterns = convert2list(get_buffer_config(self.vim, context,
                                         'b:deoplete_omni_patterns',
                                         'g:deoplete#omni_patterns',
                                         'g:deoplete#_omni_patterns'))
        # self.debug(omni_pattern)
        for pattern in omni_patterns:
            if pattern != '' \
                    and self.vim.eval('&l:omnifunc') != '' \
                    and re.search('('+pattern+')$', context['input']) \
                    and self.vim.eval('mode()') == 'i':
                self.vim.command(
                    'call feedkeys("\<C-x>\<C-o>", "n")')
                return

        try:
            complete_position, candidates = \
                self.deoplete.gather_candidates(context)
        except Exception as e:
            self.error(e)
            candidates = []
        if not candidates or self.vim.eval('mode()') != 'i':
                return
        self.vim.command(
          'let g:deoplete#_context = {}')
        self.vim.command(
          'let g:deoplete#_context.complete_position = '
            + str(complete_position))
        self.vim.command(
          'let g:deoplete#_context.changedtick = '
            + str(context['changedtick']))
        self.vim.command(
          'let g:deoplete#_context.candidates = '
            + str(candidates))
        self.vim.command(
          'call feedkeys("\<Plug>(deoplete_start_complete)")')
Пример #30
0
 def init_channel(self, args):
     self._deoplete = Deoplete(self._vim)