summaryrefslogtreecommitdiff
path: root/rplugin/python3
diff options
context:
space:
mode:
authortek <torstenschmits@gmail.com>2016-08-19 12:09:59 +0200
committertek <torstenschmits@gmail.com>2016-08-19 12:09:59 +0200
commit5334978244fdb881741d498229a404d4adf8b064 (patch)
tree416fb436aa33792ffd3d43381f63277ce860b63d /rplugin/python3
parent4f94ff7f025d9f2b9252e3399f12bdbaecb60144 (diff)
downloaddeoplete.nvim-5334978244fdb881741d498229a404d4adf8b064.zip
use pkg_resources to find neovim client version on startup
Diffstat (limited to 'rplugin/python3')
-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)