Skip to content

Commit 2cbc135

Browse files
author
Sunny Rahul
authored
import vim module by default #430
Vim-compatible. fixes neovim/neovim#11783
1 parent 9870f9a commit 2cbc135

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

pynvim/plugin/script_host.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ def __init__(self, nvim):
4343
exec('import sys', self.module.__dict__)
4444
self.legacy_vim = LegacyVim.from_nvim(nvim)
4545
sys.modules['vim'] = self.legacy_vim
46-
46+
# mimic Vim by importing vim module by default.
47+
exec('import vim', self.module.__dict__)
4748
# Handle DirChanged. #296
4849
nvim.command(
4950
'au DirChanged * call rpcnotify({}, "python_chdir", v:event.cwd)'

test/test_host.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
# -*- coding: utf-8 -*-
2-
32
from pynvim.plugin.host import Host, host_method_spec
3+
from pynvim.plugin.script_host import ScriptHost
4+
5+
6+
def test_host_imports(vim):
7+
h = ScriptHost(vim)
8+
assert h.module.__dict__['vim']
9+
assert h.module.__dict__['vim'] == h.legacy_vim
10+
assert h.module.__dict__['sys']
411

512

613
def test_host_clientinfo(vim):

0 commit comments

Comments
 (0)