File tree Expand file tree Collapse file tree 3 files changed +36
-4
lines changed Expand file tree Collapse file tree 3 files changed +36
-4
lines changed Original file line number Diff line number Diff line change @@ -8,15 +8,15 @@ Using pip
8
8
9
9
You can install the package without being root by adding the ``--user `` flag::
10
10
11
- pip2 install neovim
12
- pip3 install neovim
11
+ pip2 install --user neovim
12
+ pip3 install --user neovim
13
13
14
14
.. note ::
15
15
16
16
If you only use one of python2 or python3,
17
17
it is enough to install that version.
18
18
19
- If you follow Neovim master ,
19
+ If you follow Neovim HEAD ,
20
20
make sure to upgrade the ``python-client `` when you upgrade Neovim::
21
21
22
22
pip2 install --upgrade neovim
Original file line number Diff line number Diff line change @@ -45,6 +45,12 @@ def __init__(self, nvim):
45
45
self .legacy_vim = LegacyVim .from_nvim (nvim )
46
46
sys .modules ['vim' ] = self .legacy_vim
47
47
48
+ # Handle DirChanged. #296
49
+ nvim .command (
50
+ 'autocmd DirChanged * call rpcrequest({}, "python_chdir", v:event)'
51
+ .format (nvim .channel_id ), async = True )
52
+ os .chdir (nvim .eval ('getcwd()' , async = False ))
53
+
48
54
def setup (self , nvim ):
49
55
"""Setup import hooks and global streams.
50
56
@@ -153,6 +159,11 @@ def python_eval(self, expr):
153
159
"""Handle the `pyeval` vim function."""
154
160
return eval (expr , self .module .__dict__ )
155
161
162
+ @rpc_export ('python_chdir' , sync = True )
163
+ def python_chdir (self , args ):
164
+ """Handle working directory changes."""
165
+ os .chdir (args ['cwd' ])
166
+
156
167
def _set_current_range (self , start , stop ):
157
168
current = self .legacy_vim .current
158
169
current .range = current .buffer .range (start , stop )
Original file line number Diff line number Diff line change 1
1
# -*- coding: utf-8 -*-
2
- import os , tempfile
2
+ import os , sys , tempfile
3
3
from nose .tools import with_setup , eq_ as eq , ok_ as ok
4
4
from test_common import vim , cleanup
5
5
@@ -162,3 +162,24 @@ def test_hash():
162
162
eq (d [vim .current .buffer ], "alpha" )
163
163
vim .command ('winc w' )
164
164
eq (d [vim .current .buffer ], "beta" )
165
+
166
+
167
+ @with_setup (setup = cleanup )
168
+ def test_cwd ():
169
+ # Detect whether we're running under python2 or python3.
170
+ IS_PYTHON3 = sys .version_info >= (3 , 0 )
171
+ if IS_PYTHON3 :
172
+ pycmd = 'python3'
173
+ else :
174
+ pycmd = 'python'
175
+
176
+ vim .command ('%s import os' % pycmd )
177
+ vim .command ('cd test' )
178
+ cwd_vim = vim .command_output ('pwd' )
179
+ if IS_PYTHON3 :
180
+ cwd_python = vim .command_output ('%s print(os.getcwd())' % pycmd )
181
+ else :
182
+ cwd_python = vim .command_output ('%s print os.getcwd()' % pycmd )
183
+
184
+ eq (cwd_vim , cwd_python )
185
+
You can’t perform that action at this time.
0 commit comments