summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rplugin/python3/deoplete/__init__.py22
1 files changed, 13 insertions, 9 deletions
diff --git a/rplugin/python3/deoplete/__init__.py b/rplugin/python3/deoplete/__init__.py
index 3db7699..ab21d64 100644
--- a/rplugin/python3/deoplete/__init__.py
+++ b/rplugin/python3/deoplete/__init__.py
@@ -26,15 +26,19 @@ class DeopleteHandlers(object):
self.__vim.vars['deoplete#_channel_id'] = self.__vim.channel_id
# Check neovim-python version.
- version = []
- python_dir = os.path.dirname(os.path.dirname(neovim.__file__))
- base = python_dir + '/neovim-*/'
- for metadata in glob(base + 'PKG-INFO') + glob(base + '/METADATA'):
- with open(metadata, 'r', errors='replace') as f:
- for line in f:
- m = re.match('Version: (.+)', line)
- if m:
- version.append(m.group(1))
+ try:
+ import pkg_resources
+ version = [pkg_resources.get_distribution('neovim').version]
+ except Exception:
+ version = []
+ python_dir = os.path.dirname(os.path.dirname(neovim.__file__))
+ base = python_dir + '/neovim-*/'
+ for metadata in glob(base + 'PKG-INFO') + glob(base + '/METADATA'):
+ with open(metadata, 'r', errors='replace') as f:
+ for line in f:
+ m = re.match('Version: (.+)', line)
+ if m:
+ version.append(m.group(1))
self.__vim.vars['deoplete#_neovim_python_version'] = version
@neovim.rpc_export('deoplete_enable_logging', sync=True)