diff options
-rw-r--r-- | rplugin/python3/deoplete/context.py | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/rplugin/python3/deoplete/context.py b/rplugin/python3/deoplete/context.py index 990fa8b..403c094 100644 --- a/rplugin/python3/deoplete/context.py +++ b/rplugin/python3/deoplete/context.py @@ -4,19 +4,19 @@ # License: MIT license # ============================================================================ +import os import re -from os.path import exists - class Context(object): def __init__(self, vim): self._vim = vim self._prev_filetype = self._vim.eval('&l:filetype') - self._cached = self._init_cached() + self._cached = None self._cached_filetype = self._init_cached_filetype( self._prev_filetype) + self._init_cached() def get(self, event): text = self._vim.call('deoplete#util#get_input', event) @@ -72,12 +72,14 @@ class Context(object): bufname = '' else: bufname = self._vim.buffers[int(bufnr)].name + cwd = self._vim.call('getcwd') buftype = self._vim.current.buffer.options['buftype'] - bufpath = self._vim.call('fnamemodify', bufname, ':p') - if not exists(bufpath) or 'nofile' in buftype: + bufpath = (bufname if os.path.isabs(bufname) + else os.path.join(cwd, bufname)) + if not os.path.exists(bufpath) or 'nofile' in buftype: bufpath = '' - return { + self._cached = { 'bufnr': bufnr, 'bufname': bufname, 'bufpath': bufpath, @@ -85,7 +87,7 @@ class Context(object): 'deoplete#custom#_get_option', 'camel_case'), 'complete_str': '', 'custom': self._vim.call('deoplete#custom#_get'), - 'cwd': self._vim.call('getcwd'), + 'cwd': cwd, 'encoding': self._vim.options['encoding'], 'ignorecase': self._vim.call( 'deoplete#custom#_get_option', 'ignore_case'), |