def filter_unite(): pattern = vim.eval('input') candidates = vim.bindeval('a:candidates') regex = abbrev_matcher.make_regex(pattern) def candidate_word(candidate): return (candidate['word'] if isinstance(candidate, vim.Dictionary) else candidate) candidate_words = map(candidate_word, candidates) line_nums = filter_grep_exc_handling(regex, candidate_words) filter_by_indices(candidates, line_nums)
def filter_ctrlp(): items = vim.eval('a:items') pattern = vim.eval('a:str') limit = int(vim.eval('a:limit')) ispath = vim.eval('a:ispath') mmode = vim.eval('a:mmode') regex = abbrev_matcher.make_regex(pattern) cutter = ctrlp_mmode_cutters[mmode] mmode_items = map(cutter, items) line_nums = filter_grep_exc_handling(regex, mmode_items) filter_by_indices(items, line_nums) def rank(string): return abbrev_matcher.rank(pattern, cutter(string), is_file=ispath) items.sort(key=rank) items[limit:] = [] return items
def highlight_regex(pattern, **kwargs): regex = abbrev_matcher.make_regex(pattern, dialect='vim', **kwargs) return regex