Skip to content

Commit

Permalink
import vim module by default #430
Browse files Browse the repository at this point in the history
Vim-compatible.
fixes neovim/neovim#11783
  • Loading branch information
Sunny Rahul committed Feb 7, 2020
1 parent 9870f9a commit 2cbc135
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
3 changes: 2 additions & 1 deletion pynvim/plugin/script_host.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ def __init__(self, nvim):
exec('import sys', self.module.__dict__)
self.legacy_vim = LegacyVim.from_nvim(nvim)
sys.modules['vim'] = self.legacy_vim

# mimic Vim by importing vim module by default.
exec('import vim', self.module.__dict__)
# Handle DirChanged. #296
nvim.command(
'au DirChanged * call rpcnotify({}, "python_chdir", v:event.cwd)'
Expand Down
9 changes: 8 additions & 1 deletion test/test_host.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# -*- coding: utf-8 -*-

from pynvim.plugin.host import Host, host_method_spec
from pynvim.plugin.script_host import ScriptHost


def test_host_imports(vim):
h = ScriptHost(vim)
assert h.module.__dict__['vim']
assert h.module.__dict__['vim'] == h.legacy_vim
assert h.module.__dict__['sys']


def test_host_clientinfo(vim):
Expand Down

0 comments on commit 2cbc135

Please sign in to comment.