5
5
import os
6
6
import sys
7
7
8
- import neovim
8
+ from .decorators import plugin , rpc_export
9
+ from ..api import SessionHook
9
10
10
11
__all__ = ('ScriptHost' ,)
11
12
22
23
from importlib .machinery import PathFinder
23
24
24
25
25
- @neovim . plugin
26
+ @plugin
26
27
class ScriptHost (object ):
27
28
28
29
"""Provides an environment for running python plugins created for Vim."""
@@ -59,9 +60,6 @@ def setup(self, nvim):
59
60
60
61
def teardown (self ):
61
62
"""Restore state modified from the `setup` call."""
62
- for plugin in self .installed_plugins :
63
- if hasattr (plugin , 'on_teardown' ):
64
- plugin .teardown ()
65
63
nvim = self .nvim
66
64
info ('uninstall import hook/path' )
67
65
sys .path .remove (nvim .VIM_SPECIAL_PATH )
@@ -70,21 +68,21 @@ def teardown(self):
70
68
sys .stdout = self .saved_stdout
71
69
sys .stderr = self .saved_stderr
72
70
73
- @neovim . rpc_export ('python_execute' , sync = True )
71
+ @rpc_export ('python_execute' , sync = True )
74
72
def python_execute (self , script , range_start , range_stop ):
75
73
"""Handle the `python` ex command."""
76
74
self ._set_current_range (range_start , range_stop )
77
75
exec (script , self .module .__dict__ )
78
76
79
- @neovim . rpc_export ('python_execute_file' , sync = True )
77
+ @rpc_export ('python_execute_file' , sync = True )
80
78
def python_execute_file (self , file_path , range_start , range_stop ):
81
79
"""Handle the `pyfile` ex command."""
82
80
self ._set_current_range (range_start , range_stop )
83
81
with open (file_path ) as f :
84
82
script = compile (f .read (), file_path , 'exec' )
85
83
exec (script , self .module .__dict__ )
86
84
87
- @neovim . rpc_export ('python_do_range' , sync = True )
85
+ @rpc_export ('python_do_range' , sync = True )
88
86
def python_do_range (self , start , stop , code ):
89
87
"""Handle the `pydo` ex command."""
90
88
self ._set_current_range (start , stop )
@@ -142,7 +140,7 @@ def python_do_range(self, start, stop, code):
142
140
# delete the function
143
141
del self .module .__dict__ [fname ]
144
142
145
- @neovim . rpc_export ('python_eval' , sync = True )
143
+ @rpc_export ('python_eval' , sync = True )
146
144
def python_eval (self , expr ):
147
145
"""Handle the `pyeval` vim function."""
148
146
return eval (expr , self .module .__dict__ )
@@ -163,7 +161,7 @@ def writelines(self, seq):
163
161
self .redirect_handler ('\n ' .join (seq ))
164
162
165
163
166
- class LegacyEvalHook (neovim . SessionHook ):
164
+ class LegacyEvalHook (SessionHook ):
167
165
168
166
"""Injects legacy `vim.eval` behavior to a Nvim instance."""
169
167
0 commit comments