From aa37cd0fbe97d3b43fc37b5d23ded5bec1163686 Mon Sep 17 00:00:00 2001 From: Shougo Matsushita Date: Mon, 20 Jun 2016 20:17:36 +0900 Subject: [PATCH] Improve deoplete source performance --- rplugin/python3/deoplete/sources/neosnippet.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/rplugin/python3/deoplete/sources/neosnippet.py b/rplugin/python3/deoplete/sources/neosnippet.py index 56ecdc9..8a3c9a6 100644 --- a/rplugin/python3/deoplete/sources/neosnippet.py +++ b/rplugin/python3/deoplete/sources/neosnippet.py @@ -33,14 +33,16 @@ class Source(Base): self.name = 'neosnippet' self.mark = '[ns]' self.rank = 200 + self.__cache = {} - def gather_candidates(self, context): - return self.vim.eval( + def on_event(self, context): + self.__cache[context['filetype']] = self.vim.eval( 'values(neosnippet#helpers#get_completion_snippets())') - - def on_post_filter(self, context): - for candidate in context['candidates']: + for candidate in self.__cache[context['filetype']]: candidate['dup'] = 1 candidate['menu'] = candidate['menu_abbr'] - return context['candidates'] + def gather_candidates(self, context): + if not self.__cache: + self.on_event(context) + return self.__cache.get(context['filetype'], [])