55import os
66import sys
77
8- import neovim
8+ from .decorators import plugin , rpc_export
9+ from ..api import SessionHook
910
1011__all__ = ('ScriptHost' ,)
1112
2223 from importlib .machinery import PathFinder
2324
2425
25- @neovim . plugin
26+ @plugin
2627class ScriptHost (object ):
2728
2829 """Provides an environment for running python plugins created for Vim."""
@@ -59,9 +60,6 @@ def setup(self, nvim):
5960
6061 def teardown (self ):
6162 """Restore state modified from the `setup` call."""
62- for plugin in self .installed_plugins :
63- if hasattr (plugin , 'on_teardown' ):
64- plugin .teardown ()
6563 nvim = self .nvim
6664 info ('uninstall import hook/path' )
6765 sys .path .remove (nvim .VIM_SPECIAL_PATH )
@@ -70,21 +68,21 @@ def teardown(self):
7068 sys .stdout = self .saved_stdout
7169 sys .stderr = self .saved_stderr
7270
73- @neovim . rpc_export ('python_execute' , sync = True )
71+ @rpc_export ('python_execute' , sync = True )
7472 def python_execute (self , script , range_start , range_stop ):
7573 """Handle the `python` ex command."""
7674 self ._set_current_range (range_start , range_stop )
7775 exec (script , self .module .__dict__ )
7876
79- @neovim . rpc_export ('python_execute_file' , sync = True )
77+ @rpc_export ('python_execute_file' , sync = True )
8078 def python_execute_file (self , file_path , range_start , range_stop ):
8179 """Handle the `pyfile` ex command."""
8280 self ._set_current_range (range_start , range_stop )
8381 with open (file_path ) as f :
8482 script = compile (f .read (), file_path , 'exec' )
8583 exec (script , self .module .__dict__ )
8684
87- @neovim . rpc_export ('python_do_range' , sync = True )
85+ @rpc_export ('python_do_range' , sync = True )
8886 def python_do_range (self , start , stop , code ):
8987 """Handle the `pydo` ex command."""
9088 self ._set_current_range (start , stop )
@@ -142,7 +140,7 @@ def python_do_range(self, start, stop, code):
142140 # delete the function
143141 del self .module .__dict__ [fname ]
144142
145- @neovim . rpc_export ('python_eval' , sync = True )
143+ @rpc_export ('python_eval' , sync = True )
146144 def python_eval (self , expr ):
147145 """Handle the `pyeval` vim function."""
148146 return eval (expr , self .module .__dict__ )
@@ -163,7 +161,7 @@ def writelines(self, seq):
163161 self .redirect_handler ('\n ' .join (seq ))
164162
165163
166- class LegacyEvalHook (neovim . SessionHook ):
164+ class LegacyEvalHook (SessionHook ):
167165
168166 """Injects legacy `vim.eval` behavior to a Nvim instance."""
169167
0 commit comments