diff options
author | Shougo Matsushita <Shougo.Matsu@gmail.com> | 2018-12-17 19:56:02 +0900 |
---|---|---|
committer | Shougo Matsushita <Shougo.Matsu@gmail.com> | 2018-12-17 19:56:02 +0900 |
commit | 48bcbe06757907de62919d27dc75d51dc1deed3a (patch) | |
tree | d7c1a75523077aa5e4dde7eeaced97b48be0a85b | |
parent | ecf92225b6ba066c09f94587e78fdf8c49adaafa (diff) | |
download | deoplete.nvim-48bcbe06757907de62919d27dc75d51dc1deed3a.zip |
Fix #893 context bufpath
-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'), |