Exemple #1
0
    def gather_candidates(self, context):
        # Skip completion
        if (self.vim.eval('&l:completefunc') != '' \
                and self.vim.eval('&l:buftype').find('nofile') >= 0) \
                or (context['event'] != 'Manual' and \
                    get_simple_buffer_config(
                        self.vim,
                        'b:deoplete_disable_auto_complete',
                        'g:deoplete#disable_auto_complete')):
            return (-1, [])

        if self.vim.eval('&runtimepath') != self.runtimepath:
            # Recache
            self.load_sources()
            self.load_filters()
            self.runtimepath = self.vim.eval('&runtimepath')

        # self.debug(context)

        # Set ignorecase
        if context['smartcase'] \
                and re.search(r'[A-Z]', context['complete_str']):
            context['ignorecase'] = 0

        results = self.gather_results(context)
        return self.merge_results(results)
Exemple #2
0
    def gather_candidates(self, context):
        # Skip completion
        if (self.vim.eval('&l:completefunc') != '' \
                and self.vim.eval('&l:buftype').find('nofile') >= 0) \
                or (context['event'] != 'Manual' and \
                    get_simple_buffer_config(
                        self.vim,
                        'b:deoplete_disable_auto_complete',
                        'g:deoplete#disable_auto_complete')):
            return (-1, [])

        if self.vim.eval('&runtimepath') != self.runtimepath:
            # Recache
            self.load_sources()
            self.load_filters()
            self.runtimepath = self.vim.eval('&runtimepath')

        # self.debug(context)

        # Set ignorecase
        if context['smartcase'] \
                and re.search(r'[A-Z]', context['complete_str']):
            context['ignorecase'] = 0

        results = self.gather_results(context)
        return self.merge_results(results)
Exemple #3
0
    def gather_candidates(self, context):
        host = get_simple_buffer_config(self.vim, 'b:OmniSharp_host',
                                        'g:OmniSharp_host')
        url = "%s/autocomplete" % host
        cur = self.vim.current
        win = cur.window
        cursor = win.cursor
        buf = cur.buffer
        lines = [str(i) for i in buf[:]]

        params = {
            'line': str(cursor[0]),
            'column': str(cursor[1] + 1),
            'buffer': '\n'.join(lines),
            'filename': str(cur.buffer.name),
            'wordToComplete': context['complete_str'],
            'WantMethodHeader': True,
            'WantReturnType': True,
            'WantDocumentationForEveryCompletionResult': True
        }
        data = bytes(json.dumps(params), 'utf-8')

        req = urllib.request.Request(
            url,
            data,
            headers={'Content-Type': 'application/json; charset=UTF-8'},
            method='POST')
        with urllib.request.urlopen(req) as f:
            r = str(f.read(), 'utf-8')

        if r is None or len(r) == 0:
            return []
        l = json.loads(r)
        if l is None:
            return []

        completions = []
        for item in l:
            display = item[
                'MethodHeader'] if item['MethodHeader'] is not None and len(
                    item['MethodHeader']) > 0 else item['CompletionText']
            display += '\t'
            display += item[
                'ReturnType'] if item['ReturnType'] is not None and len(
                    item['ReturnType']) > 0 else item['DisplayText']

            completionText = item['CompletionText']
            description = item['Description'].replace(
                '\r\n', '\n') if item['Description'] is not None else ''

            completions.append(
                dict(word=completionText,
                     abbr=display,
                     info=description,
                     icase=1,
                     dup=1))

        return completions
Exemple #4
0
    def gather_candidates(self, context):
        host = get_simple_buffer_config(
                self.vim, 'b:OmniSharp_host', 'g:OmniSharp_host')
        url = "%s/autocomplete" % host
        cur = self.vim.current
        win = cur.window
        cursor = win.cursor
        buf = cur.buffer
        lines = [str(i) for i in buf[:]]

        params = {
            'line': str(cursor[0]),
            'column': str(cursor[1]+1),
            'buffer': '\n'.join(lines),
            'filename': str(cur.buffer.name),
            'wordToComplete': context['complete_str'],
            'WantMethodHeader': True,
            'WantReturnType': True,
            'WantDocumentationForEveryCompletionResult': True
        }
        data = bytes(json.dumps(params), 'utf-8')

        req = urllib.request.Request(
            url, data, headers={'Content-Type': 'application/json; charset=UTF-8'},
            method='POST')
        with urllib.request.urlopen(req) as f:
            r = str(f.read(), 'utf-8')

        if r is None or len(r) == 0:
            return []
        l = json.loads(r)
        if l is None:
            return []

        completions = []
        for item in l:
            display = item['MethodHeader'] if item['MethodHeader'] is not None and len(item['MethodHeader']) > 0 else item['CompletionText']
            display += '\t'
            display += item['ReturnType'] if item['ReturnType'] is not None and len(item['ReturnType']) > 0 else item['DisplayText']

            completionText = item['CompletionText']
            description = item['Description'].replace('\r\n', '\n') if item['Description'] is not None else ''

            completions.append(dict(
                word=completionText,
                abbr=display,
                info=description,
                icase=1,
                dup=1))

        return completions
Exemple #5
0
 def __substitute_path(self, context, path):
     buffer_path = get_simple_buffer_config(
         context, 'deoplete_file_enable_buffer_path',
         'deoplete#file#enable_buffer_path')
     m = re.match(r'(\.+)/', path)
     if m:
         h = self.vim.funcs.repeat(':h', len(m.group(1)))
         return re.sub(
             r'^\.+',
             self.vim.funcs.fnamemodify(
                 (context['bufname'] if buffer_path else context['cwd']),
                 ':p' + h), path)
     m = re.match(r'~/', path)
     if m and os.environ.get('HOME'):
         return re.sub(r'^~', os.environ.get('HOME'), path)
     m = re.match(r'\$([A-Z_]+)/', path)
     if m and os.environ.get(m.group(1)):
         return re.sub(r'^\$[A-Z_]+', os.environ.get(m.group(1)), path)
     return path
Exemple #6
0
    def gather_candidates(self, context):
        # Skip completion
        if (self.vim.eval('&l:completefunc') != ''
                and 'nofile' in self.vim.eval('&l:buftype')) or (
                    context['event'] != 'Manual' and get_simple_buffer_config(
                        self.vim, 'b:deoplete_disable_auto_complete',
                        'g:deoplete#disable_auto_complete')):
            return (-1, [])

        if self.vim.eval('&runtimepath') != self.runtimepath:
            # Recache
            self.load_sources()
            self.load_filters()
            self.runtimepath = self.vim.eval('&runtimepath')

        # debug(self.vim, context)

        results = self.gather_results(context)
        return self.merge_results(results)
    def gather_candidates(self, context):
        # Skip completion
        if (self.vim.eval("&l:completefunc") != "" and self.vim.eval("&l:buftype").find("nofile") >= 0) or (
            context["event"] != "Manual"
            and get_simple_buffer_config(
                self.vim, "b:deoplete_disable_auto_complete", "g:deoplete#disable_auto_complete"
            )
        ):
            return (-1, [])

        if self.vim.eval("&runtimepath") != self.runtimepath:
            # Recache
            self.load_sources()
            self.load_filters()
            self.runtimepath = self.vim.eval("&runtimepath")

        # debug(self.vim, context)

        results = self.gather_results(context)
        return self.merge_results(results)
Exemple #8
0
 def __substitute_path(self, context, path):
     buffer_path = get_simple_buffer_config(
         context,
         'deoplete_file_enable_buffer_path',
         'deoplete#file#enable_buffer_path')
     m = re.match(r'(\.+)/', path)
     if m:
         h = self.vim.funcs.repeat(':h', len(m.group(1)))
         return re.sub(r'^\.+',
                       self.vim.funcs.fnamemodify(
                           (context['bufname']
                            if buffer_path
                            else context['cwd']), ':p' + h),
                       path)
     m = re.match(r'~/', path)
     if m and os.environ.get('HOME'):
         return re.sub(r'^~', os.environ.get('HOME'), path)
     m = re.match(r'\$([A-Z_]+)/', path)
     if m and os.environ.get(m.group(1)):
         return re.sub(r'^\$[A-Z_]+', os.environ.get(m.group(1)), path)
     return path
Exemple #9
0
    def gather_candidates(self, context):
        # Skip completion
        if (self.vim.eval('&l:completefunc') != ''
                and 'nofile' in self.vim.eval('&l:buftype')
            ) or (context['event'] != 'Manual' and
                  get_simple_buffer_config(
                self.vim,
                'b:deoplete_disable_auto_complete',
                'g:deoplete#disable_auto_complete')):
            return (-1, [])

        if self.vim.eval('&runtimepath') != self.runtimepath:
            # Recache
            self.load_sources()
            self.load_filters()
            self.runtimepath = self.vim.eval('&runtimepath')

        # self.debug(context)

        results = self.gather_results(context)
        return self.merge_results(results)