示例#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
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
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
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
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
def test_chdir():
    pwd = vim.eval('getcwd()')
    vim.chdir('/')
    eq(vim.eval('getcwd()'), '/')
    vim.chdir(pwd)
    eq(vim.eval('getcwd()'), pwd)
示例#10
0
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
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
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
def test_chdir():
    pwd = vim.eval("getcwd()")
    vim.chdir("/")
    eq(vim.eval("getcwd()"), "/")
    vim.chdir(pwd)
    eq(vim.eval("getcwd()"), pwd)
示例#15
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}])
示例#16
0
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
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
def test_chdir():
    pwd = vim.eval('getcwd()')
    vim.chdir('/')
    eq(vim.eval('getcwd()'), '/')
    vim.chdir(pwd)
    eq(vim.eval('getcwd()'), pwd)
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
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
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}])