Esempio n. 1
0
    def __init_syntax(self):
        self.__vim.command('syntax case ignore')
        self.__vim.command('highlight default link ' +
                           self.__context['cursor_highlight'] + ' Normal')
        self.__vim.command('highlight default link deniteMode ModeMsg')
        self.__vim.command('highlight default link deniteMatched Search')
        self.__vim.command('highlight default link ' +
                           'deniteStatusLinePath Comment')
        self.__vim.command('highlight default link ' +
                           'deniteStatusLineNumber LineNR')

        for source in [x for x in self.__denite.get_current_sources()]:
            name = source.name.replace('/', '_')

            self.__vim.command(
                'highlight default link ' +
                'deniteSourceLine_' + name +
                ' Type'
            )

            syntax_line = 'syntax match %s /^%s/ nextgroup=%s keepend' % (
                'deniteSourceLine_' + name,
                escape_syntax(source.name if self.__is_multi else ''),
                source.syntax_name,
            )
            self.__vim.command(syntax_line)
            source.highlight_syntax()
Esempio n. 2
0
    def update_buffer(self):
        max = len(str(self.__candidates_len))
        linenr = ('{:' + str(max) + '}/{:' + str(max) + '}').format(
            self.__cursor + self.__win_cursor, self.__candidates_len)
        mode = '-- ' + self.__current_mode.upper() + ' -- '
        self.__bufvars['denite_statusline_mode'] = mode
        self.__bufvars['denite_statusline_sources'] = self.__statusline_sources
        self.__bufvars['denite_statusline_path'] = ('[' +
                                                    self.__context['path'] +
                                                    ']')
        self.__bufvars['denite_statusline_linenr'] = linenr

        self.__vim.command('silent! syntax clear deniteMatched')
        if self.__matched_pattern != '':
            self.__vim.command('silent! syntax match deniteMatched /' +
                               escape_syntax(self.__matched_pattern) +
                               '/ contained')

        del self.__vim.current.buffer[:]
        self.__vim.current.buffer.append([
            '%s %s' %
            (x['source'] if self.__is_multi else '', x.get('abbr', x['word']))
            for x in self.__candidates[self.__cursor:self.__cursor +
                                       self.__winheight]
        ])
        del self.__vim.current.buffer[0]

        self.__options['modified'] = False

        self.move_cursor()
Esempio n. 3
0
 def define_syntax(self):
     self.vim.command(
         "syntax region " + self.syntax_name + " start=// end=/$/ "
         "contains=deniteSource_grepHeader,deniteMatched contained"
     )
     self.vim.command(
         "syntax match deniteGrepPatterns "
         + r"/%s/ " % r"\|".join(util.escape_syntax(pattern) for pattern in self.context["__patterns"])
         + "contained containedin="
         + self.syntax_name
     )
Esempio n. 4
0
 def highlight_syntax(self):
     input_str = self.context['__input']
     self.vim.command(GREP_HEADER_SYNTAX)
     self.vim.command(GREP_FILE_SYNTAX)
     self.vim.command(GREP_FILE_HIGHLIGHT)
     self.vim.command(GREP_LINE_SYNTAX)
     self.vim.command(GREP_LINE_HIGHLIGHT)
     self.vim.command(
         'syntax region ' + self.syntax_name + ' start=// end=/$/ '
         'contains=deniteSource_grepHeader,deniteMatched contained')
     self.vim.command('syntax match deniteGrepInput /%s/ ' %
                      escape_syntax(input_str) + 'contained containedin=' +
                      self.syntax_name)
     self.vim.command('highlight default link deniteGrepInput Function')
Esempio n. 5
0
    def update_buffer(self):
        max = len(str(self.__candidates_len))
        linenr = ('{:'+str(max)+'}/{:'+str(max)+'}').format(
            self.__cursor + self.__win_cursor,
            self.__candidates_len)
        mode = '-- ' + self.__current_mode.upper() + ' -- '
        self.__bufvars['denite_statusline_mode'] = mode
        self.__bufvars['denite_statusline_sources'] = self.__statusline_sources
        self.__bufvars['denite_statusline_path'] = (
            '[' + self.__context['path'] + ']')
        self.__bufvars['denite_statusline_linenr'] = linenr

        self.__vim.command('silent! syntax clear deniteMatched')
        self.__vim.command('silent! syntax clear deniteMatchedChar')
        if self.__matched_pattern != '':
            self.__vim.command(
                'silent! syntax match deniteMatched /%s/ contained' % (
                    escape_syntax(self.__matched_pattern),
                )
            )
            self.__vim.command((
                'silent! syntax match deniteMatchedChar /[%s]/ '
                'containedin=deniteMatched contained'
            ) % re.sub(
                r'([[\]\\^-])',
                r'\\\1',
                self.__context['input'].replace(' ', '')
            ))

        del self.__vim.current.buffer[:]
        self.__vim.current.buffer.append([
            self.__get_candidate_display_text(i)
            for i in range(self.__cursor,
                           min(self.__candidates_len,
                               self.__cursor + self.__winheight))
        ])
        del self.__vim.current.buffer[0]
        self.resize_buffer()

        self.__options['modified'] = False

        self.move_cursor()
Esempio n. 6
0
    def __init_syntax(self):
        self.__vim.command('syntax case ignore')
        self.__vim.command('highlight default link deniteMode ModeMsg')
        self.__vim.command('highlight default link deniteMatched Underlined')
        self.__vim.command('highlight default link deniteMatchedChar ' +
                           self.__context['highlight_matched_char'])
        self.__vim.command('highlight default link ' +
                           'deniteStatusLinePath Comment')
        self.__vim.command('highlight default link ' +
                           'deniteStatusLineNumber LineNR')
        self.__vim.command('highlight default link ' +
                           'deniteSelectedLine Statement')

        self.__vim.command(('syntax match deniteSelectedLine /^[%s].*/' +
                            ' contains=deniteConcealedMark') % (
                                self.__context['selected_icon']))
        self.__vim.command(('syntax match deniteConcealedMark /^[ %s]/' +
                            ' conceal contained') % (
                                self.__context['selected_icon']))

        for source in [x for x in self.__denite.get_current_sources()]:
            name = source.name.replace('/', '_')
            source_name = (re.sub(r'([a-zA-Z])[a-zA-Z]+', r'\1', source.name)
                           if self.__context['short_source_names']
                           else source.name) if self.__is_multi else ''

            self.__vim.command(
                'highlight default link ' +
                'deniteSourceLine_' + name +
                ' Type'
            )

            syntax_line = ('syntax match %s /^ %s/ nextgroup=%s keepend' +
                           ' contains=deniteConcealedMark') % (
                'deniteSourceLine_' + name,
                escape_syntax(source_name),
                source.syntax_name,
            )
            self.__vim.command(syntax_line)
            source.highlight()
            source.define_syntax()
Esempio n. 7
0
    def update_buffer(self):
        max = len(str(self.__candidates_len))
        linenr = ('{:' + str(max) + '}/{:' + str(max) + '}').format(
            self.__cursor + self.__win_cursor, self.__candidates_len)
        mode = '-- ' + self.__current_mode.upper() + ' -- '
        self.__bufvars['denite_statusline_mode'] = mode
        self.__bufvars['denite_statusline_sources'] = self.__statusline_sources
        self.__bufvars['denite_statusline_path'] = ('[' +
                                                    self.__context['path'] +
                                                    ']')
        self.__bufvars['denite_statusline_linenr'] = linenr

        self.__vim.command('silent! syntax clear deniteMatched')
        self.__vim.command('silent! syntax clear deniteMatchedChar')
        if self.__matched_pattern != '':
            self.__vim.command(
                'silent! syntax match deniteMatched /%s/ contained' %
                (escape_syntax(self.__matched_pattern), ))
            self.__vim.command(
                ('silent! syntax match deniteMatchedChar /[%s]/ '
                 'containedin=deniteMatched contained') %
                re.sub(r'([[\]\\^-])', r'\\\1',
                       self.__context['input'].replace(' ', '')))

        del self.__vim.current.buffer[:]
        self.__vim.current.buffer.append([
            '%s %s' % (x['source'] if self.__is_multi else '',
                       x.get('abbr', x['word'])[:400])
            for x in self.__candidates[self.__cursor:self.__cursor +
                                       self.__winheight]
        ])
        del self.__vim.current.buffer[0]
        self.resize_buffer()

        self.__options['modified'] = False

        self.move_cursor()