From e40029e3281d314ee95c10b6adbd7a4cc91afae1 Mon Sep 17 00:00:00 2001 From: Shougo Matsushita Date: Thu, 23 Jun 2016 08:32:49 +0900 Subject: Implement version check --- rplugin/python3/deoplete/__init__.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'rplugin/python3/deoplete') diff --git a/rplugin/python3/deoplete/__init__.py b/rplugin/python3/deoplete/__init__.py index 9521c7a..bcfcf2d 100644 --- a/rplugin/python3/deoplete/__init__.py +++ b/rplugin/python3/deoplete/__init__.py @@ -5,9 +5,12 @@ # ============================================================================ import neovim +import os +import re from deoplete import logger from deoplete.deoplete import Deoplete +from glob import glob @neovim.plugin @@ -21,6 +24,18 @@ class DeopleteHandlers(object): self.__deoplete = Deoplete(self.__vim) self.__vim.vars['deoplete#_channel_id'] = self.__vim.channel_id + # Check neovim-python version. + version = 'unknown' + 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 = m.group(1) + self.__vim.vars['deoplete#_neovim_python_version'] = version + @neovim.rpc_export('deoplete_enable_logging', sync=True) def enable_logging(self, level, logfile): logger.setup(self.__vim, level, logfile) -- cgit v1.2.3