def gather_candidates(self, context): candidates = [] limit = self.vim.vars['deoplete#tag#cache_limit_size'] include_files = self.vim.call( 'neoinclude#include#get_tag_files') if self.vim.call( 'exists', '*neoinclude#include#get_tag_files') else [] for filename in [ x for x in self.vim.call( 'map', self.vim.call('tagfiles') + include_files, 'fnamemodify(v:val, ":p")') if exists(x) and getsize(x) < limit ]: mtime = getmtime(filename) if filename not in self.__cache or self.__cache[ filename].mtime != mtime: with open(filename, 'r', errors='replace') as f: new_candidates = parse_file_pattern(f, '^[^!][^\t]+') candidates += new_candidates self.__cache[filename] = TagsCacheItem( mtime, new_candidates) limit -= getsize(filename) else: candidates += self.__cache[filename].candidates p = re.compile('(?:{})$'.format(context['keyword_patterns'])) return [{'word': x} for x in candidates if p.match(x)]
def gather_candidates(self, context): candidates = [] limit = self.vim.vars["deoplete#tag#cache_limit_size"] include_files = ( self.vim.call("neoinclude#include#get_tag_files") if self.vim.call("exists", "*neoinclude#include#get_tag_files") else [] ) for filename in [ x for x in self.vim.call("map", self.vim.call("tagfiles") + include_files, 'fnamemodify(v:val, ":p")') if exists(x) and getsize(x) < limit ]: mtime = getmtime(filename) if filename not in self.__cache or self.__cache[filename].mtime != mtime: with open(filename, "r", errors="replace") as f: new_candidates = parse_file_pattern(f, "^[^!][^\t]+") candidates += new_candidates self.__cache[filename] = TagsCacheItem(mtime, new_candidates) limit -= getsize(filename) else: candidates += self.__cache[filename].candidates p = re.compile("(?:{})$".format(context["keyword_patterns"])) return [{"word": x} for x in candidates if p.match(x)]
def __make_cache(self, context): for filename in self.__get_tagfiles(): mtime = getmtime(filename) if filename not in self.__cache or self.__cache[ filename].mtime != mtime: with open(filename, 'r', errors='replace') as f: self.__cache[filename] = TagsCacheItem( mtime, parse_file_pattern(f, '^[^!][^\t]+'))
def __make_cache(self, context): for filename in self.__get_dictionaries(): mtime = getmtime(filename) if filename not in self.__cache or self.__cache[ filename].mtime != mtime: with open(filename, 'r', errors='replace') as f: self.__cache[filename] = DictCacheItem( mtime, parse_file_pattern(f, context['keyword_patterns']))
def __make_cache(self, context): for filename in self.__get_dictionaries(): mtime = getmtime(filename) if filename not in self.__cache or self.__cache[ filename].mtime != mtime: with open(filename, 'r', errors='replace') as f: self.__cache[filename] = DictCacheItem( mtime, parse_file_pattern( f, context['keyword_patterns']))
def on_event(self, context): self.__tagfiles[context['bufnr']] = self.__get_tagfiles(context) # Make cache for filename in self.__tagfiles[context['bufnr']]: mtime = getmtime(filename) if filename not in self.__cache or self.__cache[ filename].mtime != mtime: with open(filename, 'r', errors='replace') as f: self.__cache[filename] = TagsCacheItem( mtime, parse_file_pattern(f, '^[^!][^\t]+'))
def __make_cache(self, context): tagfiles = self.__get_tagfiles(context) for filename in tagfiles: mtime = getmtime(filename) if filename in self.__cache and self.__cache[ filename].mtime == mtime: continue with open(filename, 'r', errors='replace') as f: self.__cache[filename] = TagsCacheItem( mtime, [{'word': x} for x in sorted( parse_file_pattern(f, '^[^!][^\t]+'), key=str.lower)] ) return tagfiles
def __make_cache(self, context): tagfiles = self.__get_tagfiles(context) for filename in tagfiles: mtime = getmtime(filename) if filename in self.__cache and self.__cache[ filename].mtime == mtime: continue with open(filename, 'r', errors='replace') as f: self.__cache[filename] = TagsCacheItem(mtime, [{ 'word': x } for x in sorted(parse_file_pattern(f, '^[^!][^\t]+'), key=str.lower)]) return tagfiles
def gather_candidates(self, context): candidates = [] for filename in [x for x in get_dictionaries( self.vim, context['filetype']) if exists(x)]: mtime = getmtime(filename) if filename not in self.__cache or self.__cache[ filename].mtime != mtime: with open(filename, 'r', errors='replace') as f: new_candidates = parse_file_pattern( f, context['keyword_patterns']) candidates += new_candidates self.__cache[filename] = DictCacheItem( mtime, new_candidates) else: candidates += self.__cache[filename].candidates return [{'word': x} for x in candidates]
def gather_candidates(self, context): candidates = [] limit = self.vim.vars['deoplete#tag#cache_limit_size'] include_files = self.vim.call( 'neoinclude#include#get_tag_files') if self.vim.call( 'exists', '*neoinclude#include#get_tag_files') else [] for filename in [x for x in self.vim.call( 'map', self.vim.call('tagfiles') + include_files, 'fnamemodify(v:val, ":p")') if exists(x) and getsize(x) < limit]: mtime = getmtime(filename) if filename not in self.__cache or self.__cache[ filename].mtime != mtime: with open(filename, 'r', errors='replace') as f: new_candidates = parse_file_pattern( f, '^[a-zA-Z_]\w*(?=\t)') candidates += new_candidates self.__cache[filename] = TagsCacheItem( mtime, new_candidates) limit -= getsize(filename) else: candidates += self.__cache[filename].candidates return [{'word': x} for x in candidates]