def init_syntax(self, context: UserContext, is_multi: bool) -> None: for source in self._current_sources: name = re.sub('[^a-zA-Z0-9_]', '_', source.name) source_name = self._get_display_source_name( context, is_multi, source.name) self._vim.command( 'highlight default link ' + 'deniteSourceLine_' + name + ' Type' ) syntax_line = ('syntax match %s /^ %s/ nextgroup=%s keepend' + ' contains=deniteConcealedMark') % ( 'deniteSourceLine_' + name, regex_convert_str_vim(source_name) + (' ' if source_name else ''), source.syntax_name, ) self._vim.command(syntax_line) source.highlight() self._vim.command( 'syntax region ' + source.syntax_name + ' start=// end=/$/ ' 'contains=deniteMatchedRange contained') source.define_syntax()
def define_syntax(self): self.vim.command( 'syntax region ' + self.syntax_name + ' start=// end=/$/ ' 'contains=deniteSource_grepHeader,deniteMatchedRange contained') self.vim.command('syntax match deniteGrepPatterns ' + r'/%s/ ' % r'\|'.join( util.regex_convert_str_vim(pattern) for pattern in self.context['__patterns']) + 'contained containedin=' + self.syntax_name)
def define_syntax(self): self.vim.command( 'syntax region ' + self.syntax_name + ' start=// end=/$/ ' 'contains=deniteSource_grepHeader,deniteMatchedRange contained') self.vim.command( 'syntax match deniteGrepPatterns ' + r'/%s/ ' % r'\|'.join(util.regex_convert_str_vim(pattern) for pattern in self.context['__patterns']) + 'contained containedin=' + self.syntax_name)
def init_syntax(self): self._vim.command('syntax case ignore') self._vim.command('highlight default link deniteMode ModeMsg') self._vim.command('highlight default link deniteMatchedRange ' + self._context['highlight_matched_range']) 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, regex_convert_str_vim(source_name), source.syntax_name, ) self._vim.command(syntax_line) source.highlight() source.define_syntax()
def init_syntax(self): self._vim.command('syntax case ignore') self._vim.command('highlight default link deniteMode ModeMsg') self._vim.command('highlight default link deniteMatchedRange ' + self._context['highlight_matched_range']) 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, regex_convert_str_vim(source_name), source.syntax_name, ) self._vim.command(syntax_line) source.highlight() source.define_syntax()
def test_regex_convert_str_vim(): assert util.regex_convert_str_vim(r'file') == 'file'
def test_regex_convert_str_vim(): assert util.regex_convert_str_vim(r'file') == 'file'