コード例 #1
0
def host_setup():
    cleanup()
    # Spawn the python host
    vim.command(
        'let pyhost_id = ' +
        'rpcstart("python", ["-c", "import neovim; neovim.start_host()"])')
    ok(vim.eval('g:pyhost_id'))
    # Use rpc_request to wait for the host setup(rpc_spawn will return a channel
    # id but only after a while the channel will register handlers for python_*
    # methods)
    ok(vim.eval('rpcrequest(g:pyhost_id, "python_eval", "10")') == 10)
    # Verify the feature
    ok(vim.eval('has("python")'))
    # Import the vim module
    vim.command('python import vim')
    # Ensure the python host was updated accordingly
    ok(vim.eval('pyeval("vim.channel_id") == g:pyhost_id'))
コード例 #2
0
def test_name():
    vim.command('new')
    eq(vim.current.buffer.name, '')
    new_name = vim.eval('resolve(tempname())')
    vim.current.buffer.name = new_name
    eq(vim.current.buffer.name, new_name)
    vim.command('silent w!')
    ok(os.path.isfile(new_name))
    os.unlink(new_name)
コード例 #3
0
ファイル: test_buffer.py プロジェクト: kryskool/python-client
def test_name():
    vim.command("new")
    eq(vim.current.buffer.name, "")
    new_name = vim.eval("tempname()")
    vim.current.buffer.name = new_name
    eq(vim.current.buffer.name, new_name)
    vim.command("w!")
    ok(os.path.isfile(new_name))
    os.unlink(new_name)
コード例 #4
0
ファイル: test_buffer.py プロジェクト: 0x90sled/python-client
def test_name():
    vim.command('new')
    eq(vim.current.buffer.name, '')
    new_name = vim.eval('resolve(tempname())')
    vim.current.buffer.name = new_name
    eq(vim.current.buffer.name, new_name)
    vim.command('silent w!')
    ok(os.path.isfile(new_name))
    os.unlink(new_name)
コード例 #5
0
def test_sending_notify():
    # notify after notify
    vim.command("let g:test = 3", async=True)
    cmd = 'call rpcnotify(%d, "test-event", g:test)' % vim.channel_id
    vim.command(cmd, async=True)
    event = vim.session.next_message()
    eq(event[1], 'test-event')
    eq(event[2], [3])

    # request after notify
    vim.command("let g:data = 'xyz'", async=True)
    eq(vim.eval('g:data'), 'xyz')
コード例 #6
0
ファイル: test_vim.py プロジェクト: gkz/python-client
def test_list_runtime_paths():
    # Is this the default runtime path list?
    homedir = os.path.join(os.environ['HOME'], '.nvim')
    vimdir = vim.eval('$VIM')
    dflt_rtp = [
        homedir,
        os.path.join(vimdir, 'vimfiles'), vimdir,
        os.path.join(vimdir, 'vimfiles', 'after')
    ]
    # If the runtime is installed the default path
    # is nvim/runtime
    dflt_rtp2 = list(dflt_rtp)
    dflt_rtp2[2] = os.path.join(dflt_rtp2[2], 'runtime')

    rtp = vim.list_runtime_paths()
    ok(rtp == dflt_rtp or rtp == dflt_rtp2)
コード例 #7
0
ファイル: test_vim.py プロジェクト: alaric/python-client
def test_list_runtime_paths():
    # Is this the default runtime path list?
    homedir = os.path.join(os.environ['HOME'], '.nvim')
    vimdir = vim.eval('$VIM')
    dflt_rtp = [
        homedir,
        os.path.join(vimdir, 'vimfiles'),
        vimdir,
        os.path.join(vimdir, 'vimfiles', 'after')
    ]
    # If the runtime is installed the default path
    # is nvim/runtime
    dflt_rtp2 = list(dflt_rtp)
    dflt_rtp2[2] = os.path.join(dflt_rtp2[2], 'runtime')

    rtp = vim.list_runtime_paths()
    ok(rtp == dflt_rtp or rtp == dflt_rtp2)
コード例 #8
0
def test_vars():
    vim.current.buffer.vars['python'] = [1, 2, {'3': 1}]
    eq(vim.current.buffer.vars['python'], [1, 2, {'3': 1}])
    eq(vim.eval('b:python'), [1, 2, {'3': 1}])
コード例 #9
0
ファイル: test_vim.py プロジェクト: tony/python-client
def test_chdir():
    pwd = vim.eval('getcwd()')
    vim.chdir('/')
    eq(vim.eval('getcwd()'), '/')
    vim.chdir(pwd)
    eq(vim.eval('getcwd()'), pwd)
コード例 #10
0
ファイル: test_vim.py プロジェクト: alaric/python-client
def test_eval():
    vim.command('let g:v1 = "a"')
    vim.command('let g:v2 = [1, 2, {"v3": 3}]')
    eq(vim.eval('g:'), {'v1': 'a', 'v2': [1, 2, {'v3': 3}]})
コード例 #11
0
ファイル: test_vim.py プロジェクト: R4zzM/python-client
def test_vars():
    vim.vars["python"] = [1, 2, {"3": 1}]
    eq(vim.vars["python"], [1, 2, {"3": 1}])
    eq(vim.eval("g:python"), [1, 2, {"3": 1}])
コード例 #12
0
def host_teardown():
    ok(vim.eval('rpcstop(g:pyhost_id)'))
    # After the channel is closed, the feature should not be available
    ok(not vim.eval('has("python")'))
コード例 #13
0
ファイル: test_vim.py プロジェクト: R4zzM/python-client
def test_eval():
    vim.command('let g:v1 = "a"')
    vim.command('let g:v2 = [1, 2, {"v3": 3}]')
    eq(vim.eval("g:"), {"v1": "a", "v2": [1, 2, {"v3": 3}]})
コード例 #14
0
ファイル: test_vim.py プロジェクト: R4zzM/python-client
def test_chdir():
    pwd = vim.eval("getcwd()")
    vim.chdir("/")
    eq(vim.eval("getcwd()"), "/")
    vim.chdir(pwd)
    eq(vim.eval("getcwd()"), pwd)
コード例 #15
0
ファイル: test_buffer.py プロジェクト: kryskool/python-client
def test_vars():
    vim.current.buffer.vars["python"] = [1, 2, {"3": 1}]
    eq(vim.current.buffer.vars["python"], [1, 2, {"3": 1}])
    eq(vim.eval("b:python"), [1, 2, {"3": 1}])
コード例 #16
0
ファイル: test_vim.py プロジェクト: tony/python-client
def test_vars():
    vim.vars['python'] = [1, 2, {'3': 1}]
    eq(vim.vars['python'], [1, 2, {'3': 1}])
    eq(vim.eval('g:python'), [1, 2, {'3': 1}])
コード例 #17
0
ファイル: test_vim.py プロジェクト: tony/python-client
def test_eval():
    vim.command('let g:v1 = "a"')
    vim.command('let g:v2 = [1, 2, {"v3": 3}]')
    eq(vim.eval('g:'), {'v1': 'a', 'v2': [1, 2, {'v3': 3}]})
コード例 #18
0
ファイル: test_vim.py プロジェクト: alaric/python-client
def test_chdir():
    pwd = vim.eval('getcwd()')
    vim.chdir('/')
    eq(vim.eval('getcwd()'), '/')
    vim.chdir(pwd)
    eq(vim.eval('getcwd()'), pwd)
コード例 #19
0
def test_python_command_with_range():
    vim.feedkeys('iline1\nline2\nline3\nline4\033')
    vim.feedkeys('ggjvj:python vim.vars["range"] = vim.current.range[:]\n')
    vim.eval('1') # wait for the keys to be processed
    eq(vim.vars['range'], ['line2', 'line3'])
コード例 #20
0
def test_vars():
    vim.current.window.vars['python'] = [1, 2, {'3': 1}]
    eq(vim.current.window.vars['python'], [1, 2, {'3': 1}])
    eq(vim.eval('w:python'), [1, 2, {'3': 1}])
コード例 #21
0
ファイル: test_buffer.py プロジェクト: 0x90sled/python-client
def test_vars():
    vim.current.buffer.vars['python'] = [1, 2, {'3': 1}]
    eq(vim.current.buffer.vars['python'], [1, 2, {'3': 1}])
    eq(vim.eval('b:python'), [1, 2, {'3': 1}])
コード例 #22
0
ファイル: test_vim.py プロジェクト: alaric/python-client
def test_vars():
    vim.vars['python'] = [1, 2, {'3': 1}]
    eq(vim.vars['python'], [1, 2, {'3': 1}])
    eq(vim.eval('g:python'), [1, 2, {'3': 1}])
コード例 #23
0
def test_vars():
    vim.current.tabpage.vars['python'] = [1, 2, {'3': 1}]
    eq(vim.current.tabpage.vars['python'], [1, 2, {'3': 1}])
    eq(vim.eval('t:python'), [1, 2, {'3': 1}])