summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShougo Matsushita <Shougo.Matsu@gmail.com>2016-06-05 18:42:38 +0900
committerShougo Matsushita <Shougo.Matsu@gmail.com>2016-06-05 18:42:38 +0900
commit4350eec0a9e0eb946bee5763c356d5adc9398a39 (patch)
treededb9bbdddbaaa31dbed19325fd9acb5b7d57ac0
parent7e75db4748653102d5c2c44183070601f617a350 (diff)
downloaddeoplete.nvim-4350eec0a9e0eb946bee5763c356d5adc9398a39.zip
Improve get_simple_buffer_config implementation
-rw-r--r--rplugin/python3/deoplete/sources/file.py16
-rw-r--r--rplugin/python3/deoplete/util.py7
2 files changed, 12 insertions, 11 deletions
diff --git a/rplugin/python3/deoplete/sources/file.py b/rplugin/python3/deoplete/sources/file.py
index da88ba9..3065551 100644
--- a/rplugin/python3/deoplete/sources/file.py
+++ b/rplugin/python3/deoplete/sources/file.py
@@ -30,10 +30,10 @@ class Source(Base):
return pos if pos < 0 else pos + 1
def gather_candidates(self, context):
- p = self.__longest_path_that_exists(context['input'])
+ p = self.__longest_path_that_exists(context, context['input'])
if p in (None, []) or p == '/' or re.search('//+$', p):
return []
- complete_str = self.__substitute_path(dirname(p) + '/')
+ complete_str = self.__substitute_path(context, dirname(p) + '/')
if not os.path.isdir(complete_str):
return []
hidden = context['complete_str'].find('.') == 0
@@ -50,22 +50,22 @@ class Source(Base):
return [{'word': x, 'abbr': x + '/'} for x in dirs
] + [{'word': x} for x in files]
- def __longest_path_that_exists(self, input_str):
+ def __longest_path_that_exists(self, context, input_str):
data = re.split(self.vim.call(
'deoplete#util#vimoption2python_not',
self.vim.options['isfname']), input_str)
pos = [" ".join(data[i:]) for i in range(len(data))]
existing_paths = list(filter(lambda x: exists(
- dirname(self.__substitute_path(x))), pos))
+ dirname(self.__substitute_path(context, x))), pos))
if existing_paths and len(existing_paths) > 0:
return sorted(existing_paths)[-1]
return None
- def __substitute_path(self, path):
+ def __substitute_path(self, context, path):
buffer_path = get_simple_buffer_config(
- self.vim,
- 'b:deoplete_file_enable_buffer_path',
- 'g:deoplete#file#enable_buffer_path')
+ context,
+ 'deoplete_file_enable_buffer_path',
+ 'deoplete#file#enable_buffer_path')
m = re.match(r'(\.+)/', path)
if m:
h = self.vim.funcs.repeat(':h', len(m.group(1)))
diff --git a/rplugin/python3/deoplete/util.py b/rplugin/python3/deoplete/util.py
index 5c32f24..9e82172 100644
--- a/rplugin/python3/deoplete/util.py
+++ b/rplugin/python3/deoplete/util.py
@@ -16,9 +16,10 @@ def get_buffer_config(vim, filetype, buffer_var, user_var, default_var):
filetype, buffer_var, user_var, default_var)
-def get_simple_buffer_config(vim, buffer_var, user_var):
- return vim.call('deoplete#util#get_simple_buffer_config',
- buffer_var, user_var)
+def get_simple_buffer_config(context, buffer_var, user_var):
+ return (context['bufvars'][buffer_var]
+ if buffer_var in context['bufvars']
+ else context['vars'][user_var])
def set_pattern(vim, variable, keys, pattern):