@@ -33,7 +33,7 @@ def __init__(self, nvim):
33
33
self ._notification_handlers = {}
34
34
self ._request_handlers = {
35
35
'poll' : lambda : 'ok' ,
36
- 'specs' : lambda path : self ._specs [ path ] ,
36
+ 'specs' : lambda path : self ._specs . get ( path , []) ,
37
37
'shutdown' : self .shutdown
38
38
}
39
39
self ._nvim_encoding = nvim .options ['encoding' ]
@@ -81,23 +81,25 @@ def _on_notification(self, name, args):
81
81
def _load (self , plugins ):
82
82
for path in plugins :
83
83
if path in self ._loaded :
84
- raise Exception ('{0} is already loaded' .format (path ))
84
+ error ('{0} is already loaded' .format (path ))
85
+ continue
85
86
directory , name = os .path .split (os .path .splitext (path )[0 ])
86
87
file , pathname , description = find_module (name , [directory ])
88
+ handlers = []
87
89
try :
88
90
module = imp .load_module (name , file , pathname , description )
89
- except ImportError :
90
- error ('Encountered import error loading plugin at {0}' .format (
91
- path ))
91
+ self ._discover_classes (module , handlers , path )
92
+ self ._discover_functions (module , handlers , path )
93
+ if not handlers :
94
+ error ('{0} exports no handlers' .format (path ))
95
+ continue
96
+ self ._loaded [path ] = {'handlers' : handlers , 'module' : module }
97
+ except (ImportError , SyntaxError ) as e :
98
+ error (('Encountered import error loading '
99
+ 'plugin at {0}: {1}' ).format (path , e ))
92
100
except Exception as e :
93
101
error ('Error loading plugin at {0} {1}: {2}' .format (
94
102
path , type (e ).__name__ , e ))
95
- handlers = []
96
- self ._discover_classes (module , handlers , path )
97
- self ._discover_functions (module , handlers , path )
98
- if not handlers :
99
- raise Exception ('{0} exports no handlers' .format (path ))
100
- self ._loaded [path ] = {'handlers' : handlers , 'module' : module }
101
103
102
104
def _unload (self ):
103
105
for path , plugin in self ._loaded .items ():
0 commit comments