55import os
66import os .path
77import re
8+ import sys
89from functools import partial
910from traceback import format_exc
1011
1112from . import script_host
1213from ..api import decode_if_bytes , walk
1314from ..compat import IS_PYTHON3 , find_module
1415from ..msgpack_rpc import ErrorResponse
15- from ..util import format_exc_skip
16+ from ..util import VERSION , format_exc_skip
1617
1718__all__ = ('Host' )
1819
1920logger = logging .getLogger (__name__ )
2021error , debug , info , warn = (logger .error , logger .debug , logger .info ,
2122 logger .warning ,)
2223
24+ host_method_spec = {"poll" : {}, "specs" : {"nargs" : 1 }, "shutdown" : {}}
25+
2326
2427class Host (object ):
2528
@@ -116,6 +119,7 @@ def _missing_handler_error(self, name, kind):
116119 return msg
117120
118121 def _load (self , plugins ):
122+ has_script = False
119123 for path in plugins :
120124 err = None
121125 if path in self ._loaded :
@@ -124,6 +128,7 @@ def _load(self, plugins):
124128 try :
125129 if path == "script_host.py" :
126130 module = script_host
131+ has_script = True
127132 else :
128133 directory , name = os .path .split (os .path .splitext (path )[0 ])
129134 file , pathname , descr = find_module (name , [directory ])
@@ -141,6 +146,17 @@ def _load(self, plugins):
141146 error (err )
142147 self ._load_errors [path ] = err
143148
149+ if len (plugins ) == 1 and has_script :
150+ kind = "script"
151+ else :
152+ kind = "rplugin"
153+ name = "python{}-{}-host" .format (sys .version_info [0 ], kind )
154+ attributes = {"license" : "Apache v2" ,
155+ "website" : "github.com/neovim/python-client" }
156+ self .nvim .api .set_client_info (
157+ name , VERSION .__dict__ , "host" , host_method_spec ,
158+ attributes , async_ = True )
159+
144160 def _unload (self ):
145161 for path , plugin in self ._loaded .items ():
146162 handlers = plugin ['handlers' ]
0 commit comments