5
5
import os
6
6
import os .path
7
7
import re
8
+ import sys
8
9
from functools import partial
9
10
from traceback import format_exc
10
11
11
12
from . import script_host
12
13
from ..api import decode_if_bytes , walk
13
14
from ..compat import IS_PYTHON3 , find_module
14
15
from ..msgpack_rpc import ErrorResponse
15
- from ..util import format_exc_skip
16
+ from ..util import VERSION , format_exc_skip
16
17
17
18
__all__ = ('Host' )
18
19
19
20
logger = logging .getLogger (__name__ )
20
21
error , debug , info , warn = (logger .error , logger .debug , logger .info ,
21
22
logger .warning ,)
22
23
24
+ host_method_spec = {"poll" : {}, "specs" : {"nargs" : 1 }, "shutdown" : {}}
25
+
23
26
24
27
class Host (object ):
25
28
@@ -116,6 +119,7 @@ def _missing_handler_error(self, name, kind):
116
119
return msg
117
120
118
121
def _load (self , plugins ):
122
+ has_script = False
119
123
for path in plugins :
120
124
err = None
121
125
if path in self ._loaded :
@@ -124,6 +128,7 @@ def _load(self, plugins):
124
128
try :
125
129
if path == "script_host.py" :
126
130
module = script_host
131
+ has_script = True
127
132
else :
128
133
directory , name = os .path .split (os .path .splitext (path )[0 ])
129
134
file , pathname , descr = find_module (name , [directory ])
@@ -141,6 +146,17 @@ def _load(self, plugins):
141
146
error (err )
142
147
self ._load_errors [path ] = err
143
148
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
+
144
160
def _unload (self ):
145
161
for path , plugin in self ._loaded .items ():
146
162
handlers = plugin ['handlers' ]
0 commit comments