本文整理汇总了Python中vim.eval方法的典型用法代码示例。如果您正苦于以下问题:Python vim.eval方法的具体用法?Python vim.eval怎么用?Python vim.eval使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vim
的用法示例。
在下文中一共展示了vim.eval方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _get_cell_boundaries
# 需要导入模块: import vim [as 别名]
# 或者: from vim import eval [as 别名]
def _get_cell_boundaries():
"""Return a list of rows (1-indexed) for all cell boundaries."""
buffer = vim.current.buffer
delimiter = vim.eval('g:ipython_cell_delimit_cells_by').strip()
if delimiter == 'marks':
valid_marks = vim.eval('g:ipython_cell_valid_marks').strip()
cell_boundaries = _get_rows_with_marks(buffer, valid_marks)
elif delimiter == 'tags':
tag = vim.eval('g:ipython_cell_tag')
cell_boundaries = _get_rows_with_tag(buffer, tag)
else:
_error("Invalid option value for g:ipython_cell_valid_marks: {}"
.format(delimiter))
return
# Include beginning of file as a cell boundary
cell_boundaries.append(1)
return sorted(set(cell_boundaries))
示例2: remove_player
# 需要导入模块: import vim [as 别名]
# 或者: from vim import eval [as 别名]
def remove_player(session=None):
global players, controllers, current
if session is None:
session = int(vim.eval("v:count"))
print "removing session %d..." % (session,),
apc = controllers.get(session, None)
if apc is not None:
try:
apc.quit()
except:
pass
del controllers[session]
timelib.sleep(2)
p = players.get(session, None)
if p:
rv = p.wait()
del players[session]
if controllers:
current = controllers.values()[0]
else:
current = None
print rv
示例3: get_project_dir
# 需要导入模块: import vim [as 别名]
# 或者: from vim import eval [as 别名]
def get_project_dir():
global _project_dir
if not _project_dir:
cwd = os.getcwd()
os.chdir(vim.eval("expand('%:p:h')")) # Directory of current file.
try:
while not os.path.isfile("project.godot"):
os.chdir("..")
if os.getcwd() == "/":
return
_project_dir = os.getcwd()
except:
pass
finally:
os.chdir(cwd)
return _project_dir
示例4: highlight_line
# 需要导入模块: import vim [as 别名]
# 或者: from vim import eval [as 别名]
def highlight_line(group, buf_number, line_number):
match_id = int(vim.buffers[buf_number].vars.get('_roast_match_id', 0))
if match_id:
win = None
for win in vim.windows:
if win.buffer.number == buf_number:
break
try:
vim.eval(f'matchdelete({match_id})' if win is None else f'matchdelete({match_id}, {win.number})')
except vim.error:
# TODO: Only hide E803 error, which is thrown if this match_id has already been deleted.
pass
vim.buffers[buf_number].vars['_roast_match_id'] = vim.eval(
fr"matchadd('{group}', '\V' . escape(getbufline({buf_number}, {line_number + 1})[0], '\') . '\$')"
)
示例5: check_now
# 需要导入模块: import vim [as 别名]
# 或者: from vim import eval [as 别名]
def check_now(self):
log("Checking background threads output")
outputs = self.__process_pool.get_outputs()
changed_processes = set()
for output in outputs:
if output[1] is not None:
log("Process %s has finished with exit status %s"
%(output[0], output[1]))
process = self.__processes.update(*output)
changed_processes.add(process)
for process in changed_processes:
self.__process_renderer.update_process(process)
self.__process_pool.cleanup()
if self.__processes.all_finished():
log("All background threads completed")
self.__unassign_autocommands()
else:
s = 'feedkeys("\\%s")' % Options.refresh_key()
log(s)
vim.eval(s)
示例6: update_buffers
# 需要导入模块: import vim [as 别名]
# 或者: from vim import eval [as 别名]
def update_buffers(req):
b1_id = int(vim.eval("s:b1"))
b1 = vim.buffers[b1_id]
b2_id = int(vim.eval("s:b2"))
b2 = vim.buffers[b2_id]
# Set up the buffers
set_buffer_content(b1, req.full_message())
if req.response is not None:
set_buffer_content(b2, req.response.full_message())
# Save the port, ssl, host setting
vim.command("let s:dest_port=%d" % req.dest_port)
vim.command("let s:dest_host='%s'" % escape(req.dest_host))
if req.use_tls:
vim.command("let s:use_tls=1")
else:
vim.command("let s:use_tls=0")
示例7: set_up_windows
# 需要导入模块: import vim [as 别名]
# 或者: from vim import eval [as 别名]
def set_up_windows():
reqid = vim.eval("a:2")
storage_id = vim.eval("a:3")
msg_addr = vim.eval("a:4")
vim.command("let s:storage_id=%d" % int(storage_id))
# Get the left buffer
vim.command("new")
vim.command("only")
b2 = vim.current.buffer
vim.command("let s:b2=bufnr('$')")
# Vsplit new file
vim.command("vnew")
b1 = vim.current.buffer
vim.command("let s:b1=bufnr('$')")
print msg_addr
comm_type, comm_addr = msg_addr.split(":", 1)
set_conn(comm_type, comm_addr)
with ProxyConnection(kind=comm_type, addr=comm_addr) as conn:
# Get the request
req = conn.req_by_id(reqid, int(storage_id))
update_buffers(req)
示例8: get_variable
# 需要导入模块: import vim [as 别名]
# 或者: from vim import eval [as 别名]
def get_variable(v_name, default=None):
''' get variable from Vim
return:
vim_variable # buffer variable tried first, global variable second
default # if no variable exists, or module used independently
# from Vim session.
'''
if independent_session:
return default
if vim.eval("exists('b:'.'{0}')".format(v_name))=='0':
if vim.eval("exists('g:'.'{0}')".format(v_name))=='0':
if vim.eval("exists('{0}')".format(v_name))=='0':
return default
else:
return vim.eval(v_name)
else:
return vim.eval('g:'+v_name)
else:
return vim.eval('b:'+v_name)
示例9: ctrlp_match
# 需要导入模块: import vim [as 别名]
# 或者: from vim import eval [as 别名]
def ctrlp_match():
"""
Deprecated interface that gets arguments by calling vim.eval() and returns
outputs by calling vim.command(). Kept for Denite. Use ctrlp_match_with()
or cpsm_py.ctrlp_match() in new code.
"""
# TODO: a:regex is unimplemented.
results, regexes = ctrlp_match_with(
items=_vim_eval("a:items"), query=_vim_eval("a:str"),
limit=int(_vim_eval("a:limit")), mmode=_vim_eval("a:mmode"),
ispath=int(_vim_eval("a:ispath")), crfile=_vim_eval("a:crfile"),
highlight_mode=_vim_eval("g:cpsm_highlight_mode"),
match_crfile=int(_vim_eval("s:match_crfile")),
max_threads=int(_vim_eval("g:cpsm_max_threads")),
query_inverting_delimiter=_vim_eval("g:cpsm_query_inverting_delimiter"),
regex_line_prefix=_vim_eval("s:regex_line_prefix"),
unicode=int(_vim_eval("g:cpsm_unicode")))
vim.command("let s:results = [%s]" % ",".join(
map(_escape_and_quote, results)))
vim.command("let s:regexes = [%s]" % ",".join(
map(_escape_and_quote, regexes)))
示例10: get_encoding
# 需要导入模块: import vim [as 别名]
# 或者: from vim import eval [as 别名]
def get_encoding():
# return current documents character encoding.
return vim.eval("&fileencoding") or vim.eval("&encoding")
示例11: test_count
# 需要导入模块: import vim [as 别名]
# 或者: from vim import eval [as 别名]
def test_count():
print (int(vim.eval("v:count")))
示例12: insert_viminfo
# 需要导入模块: import vim [as 别名]
# 或者: from vim import eval [as 别名]
def insert_viminfo():
"""Insert a vim line with tabbing related settings reflecting current settings."""
# The following line is to prevent this vim from interpreting it as a real
# v-i-m tagline.
vi = ["# %s" % ("".join(['v','i','m']),)]
for var in ('ts', 'sw', 'softtabstop'):
vi.append("%s=%s" % (var, vim.eval("&%s" % (var,))))
for var in ('smarttab', 'expandtab'):
if int(vim.eval("&%s" % var)):
vi.append(var)
if vim.eval("&ft") != "python":
vi.append("ft=python")
vim.current.range.append(":".join(vi))
示例13: balloonhelp
# 需要导入模块: import vim [as 别名]
# 或者: from vim import eval [as 别名]
def balloonhelp():
try:
result = eval(vim.eval("v:beval_text")).__doc__
if result is None:
return "No doc."
result = result.replace("\0", " ")
result = result.replace('"', '\\"')
return2vim(result)
except:
ex, val, tb = sys.exc_info()
print(str(val))
return2vim("")
# XXX is this hack really necessary?
示例14: keyword_help
# 需要导入模块: import vim [as 别名]
# 或者: from vim import eval [as 别名]
def keyword_help():
devhelpers.showdoc(vim.eval('expand("<cword>")'))
示例15: keyword_view
# 需要导入模块: import vim [as 别名]
# 或者: from vim import eval [as 别名]
def keyword_view():
devhelpers.view(vim.eval('expand("<cword>")'))