本文整理汇总了Python中vim.bindeval函数的典型用法代码示例。如果您正苦于以下问题:Python bindeval函数的具体用法?Python bindeval怎么用?Python bindeval使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bindeval函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: on_done
def on_done(self, should_open, returncode):
if self._run_command and self._output_file_path:
if vim.bindeval("g:pantondoc_use_message_buffers") and returncode != '0':
vim.command("let split = &splitbelow")
vim.command("set splitbelow")
vim.command("5new pandoc\ output")
vim.command("let &splitbelow = split")
vim.command("setlocal wrap")
vim.command("setlocal linebreak")
vim.current.buffer[0] = "# Press <Esc> to close this"
vim.current.buffer.append("▶ " + self._run_command)
vim.command("normal! G")
if vim.bindeval('filereadable("pandoc.out")'):
vim.command("silent r pandoc.out")
vim.command("setlocal buftype=nofile")
vim.command("setlocal nobuflisted")
# pressing <esc> on the buffer will delete it
vim.command("map <buffer> <esc> :bd<cr>")
# we will highlight some elements in the buffer
vim.command("syn match PandocOutputMarks /^>>/")
vim.command("syn match PandocCommand /^▶.*$/hs=s+1")
vim.command("syn match PandocInstructions /^#.*$/")
vim.command("hi! link PandocOutputMarks Operator")
vim.command("hi! link PandocCommand Statement")
vim.command("hi! link PandocInstructions Comment")
if os.path.exists("pandoc.out"):
os.remove("pandoc.out")
vim.command("echohl Statement")
vim.command("echom 'pantondoc:execute:" + self._run_command + "'")
vim.command("echohl None")
# open file if needed
if os.path.exists(self._output_file_path) and should_open:
if sys.platform == "darwin":
pandoc_open_command = "open" #OSX
elif sys.platform.startswith("linux"):
pandoc_open_command = "xdg-open" # freedesktop/linux
elif sys.platform.startswith("win"):
pandoc_open_command = 'cmd /c \"start' # Windows
# On windows, we pass commands as an argument to `start`,
# which is a cmd.exe builtin, so we have to quote it
if sys.platform.startswith("win"):
pandoc_open_command_tail = '"'
else:
pandoc_open_command_tail = ''
pid = Popen([pandoc_open_command, self._output_file_path + pandoc_open_command_tail])
# we reset this
self._output_file_path = None
self._run_command = None
开发者ID:ehamberg,项目名称:vim-pantondoc,代码行数:53,代码来源:command.py
示例2: run
def run(self):
while not self.stopped:
try:
available = vim.bindeval('getchar(1)')
if available == 0:
try:
callback = self.thunkQueue.get(False)
callback()
except Queue.Empty:
time.sleep(0.01)
else:
char = vim.bindeval('getchar()')
self.charCallback(char)
except KeyboardInterrupt:
self.charCallback(key_val('<C-c>'))
开发者ID:volkhin,项目名称:vimrc,代码行数:15,代码来源:fbvimtypeahead.py
示例3: vim_extend
def vim_extend(val, var='d', utf=True, list=False):
d_vim = vim.bindeval(var)
if list:
d_vim.extend(val)
else:
for key in val:
d_vim[key] = val[key]
开发者ID:skeept,项目名称:dotvim,代码行数:7,代码来源:auutils.py
示例4: parse
def parse():
"""
Python implementation of maktaba#json#Parse().
Arguments and return values are passed using a Vim list named 'l:buffer',
as follows:
l:buffer[0] - the mapping of null/true/false to the (possibly-custom) Vim
values.
l:buffer[1] - the Vim string to parse.
l:buffer[2] - (out) the Vim value result.
l:buffer[3] - (out) the error message, if there is an error.
"""
buffer = vim.bindeval('l:buffer')
custom_values = buffer[0]
json_str = buffer[1]
try:
value = [json.loads(json_str)]
except ValueError as e:
buffer[3] = e.message
return
# Now mutate the resulting Python object to something that can be stored
# in a Vim value (i.e. has no None values, which Vim won't accept).
_py2vim_list_inplace(
value,
custom_values['null'], custom_values['true'], custom_values['false'])
buffer[2] = value[0]
开发者ID:noscripter,项目名称:vim-maktaba,代码行数:30,代码来源:maktabajson.py
示例5: __search_usr_and_rename_refs
def __search_usr_and_rename_refs(tu, usr, new_name):
if tu is None:
return
symbols = []
clighter_helper.find_cursors_by_usr(tu.cursor, usr, symbols)
if not symbols:
return
# all symbols with the same name
old_name = clighter_helper.get_spelling_or_displayname(symbols[0])
locs = set()
for sym in symbols:
clighter_helper.search_ref_tokens(tu, sym, locs)
if len(locs):
if vim.vars['clighter_rename_prompt_level'] >= 1:
if vim.bindeval(
"confirm(\"found symbols in {0}, rename them?\", \"&Yes\n&No\", 1)".format(
vim.current.buffer.name)) == 2:
return
__vim_multi_replace(
locs,
old_name,
new_name,
vim.vars['clighter_rename_prompt_level'])
开发者ID:borman,项目名称:clighter,代码行数:29,代码来源:refactor.py
示例6: vim_get_func
def vim_get_func(f, rettype=None):
'''Return a vim function binding.'''
try:
func = vim.bindeval('function("' + f + '")')
except vim.error:
return None
else:
return rettype_func[rettype](func)
开发者ID:13768324554,项目名称:powerline,代码行数:8,代码来源:__init__.py
示例7: sort_unite
def sort_unite():
candidates = vim.bindeval('a:candidates')
is_file = vim.eval('is_file')
pattern = vim.eval('a:context.input')
for candidate in candidates:
word = candidate['word']
rank = abbrev_matcher.rank(pattern, word, is_file=is_file)
candidate['filter__rank'] = rank
开发者ID:jamesfrank,项目名称:vimfiles,代码行数:9,代码来源:abbrev_matcher_vim.py
示例8: get_ignored_modules
def get_ignored_modules(self):
""" Update the ignored modules list. """
# Get the ignored modules setting as a string.
ignored_modules = vim.bindeval('g:vimpy_ignored_modules')
ignored_modules = ignored_modules.split(',')
# Remove all empty items from resulting list.
return filter(None, ignored_modules)
开发者ID:FelikZ,项目名称:vimpy,代码行数:9,代码来源:vimpy_setup.py
示例9: vim_get_func
def vim_get_func(f, rettype=None):
'''Return a vim function binding.'''
try:
func = vim.bindeval('function("' + f + '")')
if sys.version_info >= (3,) and rettype is str:
return (lambda *args, **kwargs: func(*args, **kwargs).decode('utf-8', errors='replace'))
return func
except vim.error:
return None
开发者ID:sbuys,项目名称:dotfiles,代码行数:9,代码来源:__init__.py
示例10: filter
def filter(self, items, pat, limit, mmode, ispath, crfile, regexp):
if not pat:
self.logger.debug("No pattern, returning original items")
self.queue.put(self.initialList(items, limit, ispath, crfile), timeout=1)
self.process(pat)
return
self.logger.debug("Filtering {number} items using {pat}".format(number = len(items), pat=pat))
self.process(pat)
if self.lastpat == pat and self.lastmmode == mmode \
and self.lastispath == ispath and self.lastregexp == regexp:
if self.process(pat) and self.queue.qsize() == 0 and not self.thread.isAlive():
self.logger.debug("Thread job is processed for {pat}".format(pat=pat))
self.lastpat = None
elif self.thread.isAlive() or self.queue.qsize() > 0:
self.logger.debug("Waiting for thread job for {pat}".format(pat=pat))
self.forceCursorHold()
else:
self.logger.debug("The same pattern '{pat}'".format(pat=pat))
elif pat:
self.logger.debug("Starting thread for {pat}".format(pat=pat))
self.patterns.append(pat)
mru = vim.bindeval('ctrlp#mrufiles#list()')
mru = list(mru)[:50] if isinstance(mru, vim.List) else []
self.thread = Thread(target=thread_worker, args=(
self.queue, items, pat, limit,
mmode, ispath, crfile, regexp, mru,
vim.bindeval('&ic'), vim.bindeval('&scs'), self.logger
))
self.thread.daemon = True
self.thread.start()
self.lastpat = pat
self.lastmmode = mmode
self.lastispath = ispath
self.lastregexp = regexp
self.forceCursorHold()
开发者ID:urandom,项目名称:ctrlp.vim,代码行数:44,代码来源:matcher.py
示例11: Cljfmt
def Cljfmt(code):
repl = create_or_get_repl()
job = CljfmtJob(repl, code)
job.start()
formatted_code = job.wait()
if not formatted_code:
pass
else:
vl = vim.bindeval("s:formatted_code")
vl.extend(formatted_code.split("\n"))
开发者ID:raymond-w-ko,项目名称:dot,代码行数:10,代码来源:plasmaplace.py
示例12: execute
def execute(self, should_open):
with open("pandoc.out", 'w') as tmp:
if vim.bindeval("has('clientserver')"):
async_runner = os.path.join(os.path.dirname(__file__), "async.py")
servername_arg = "--servername=" + vim.bindeval("v:servername")
open_arg = "--open" if should_open else "--noopen"
async_command = " ".join([async_runner, servername_arg, open_arg, self._run_command])
try:
pid = Popen(shlex.split(async_command), stdout=tmp, stderr=tmp)
except:
vim.command('echoe "pantondoc: could not execute pandoc asynchronously"')
else:
try:
com = Popen(shlex.split(self._run_command), stdout=tmp, stderr=tmp)
com.wait()
except:
vim.command('echoe "pantondoc: could not execute pandoc"')
return
self.on_done(should_open, com.returncode)
开发者ID:ehamberg,项目名称:vim-pantondoc,代码行数:20,代码来源:command.py
示例13: _vimify
def _vimify(obj):
"""Convert a dict, list, etc. into a vim-consumable format"""
if isinstance(obj, dict):
d = vim.bindeval("{}")
for key, val in obj.iteritems():
key = str(key)
try:
d[key] = _vimify(val)
except TypeError, e:
print "Failed to convert ", val
raise e
return d
开发者ID:dhleong,项目名称:hubr,代码行数:12,代码来源:hubr_vim.py
示例14: filter_unite
def filter_unite():
pattern = vim.eval('input')
candidates = vim.bindeval('a:candidates')
regex = abbrev_matcher.make_regex(pattern)
def candidate_word(candidate):
return (candidate['word']
if isinstance(candidate, vim.Dictionary) else candidate)
candidate_words = map(candidate_word, candidates)
line_nums = filter_grep_exc_handling(regex, candidate_words)
filter_by_indices(candidates, line_nums)
开发者ID:jamesfrank,项目名称:vimfiles,代码行数:13,代码来源:abbrev_matcher_vim.py
示例15: hubr_to_vim
def hubr_to_vim(bindName, result):
"""Called from vim to copy the method result
back into vim-space
"""
if type(result) == HubrResult:
result = {
'status': result.get_status(),
'next': result.next(),
'json': result.json()
}
d = vim.bindeval(bindName)
vimified = _vimify(result)
d['result'] = vimified
开发者ID:dhleong,项目名称:hubr,代码行数:14,代码来源:hubr_vim.py
示例16: vimfunc
def vimfunc(funcname, *args):
countermap = localstate.cache('vimfunc_countermap', lambda: {})
counter = countermap.setdefault('count', 0)
countermap['count'] = counter + 1
vim_arg_list_name = 'g:__vimfunc__arg_map_' + str(counter)
vc('let %s = []' % (vim_arg_list_name))
arg_list = vim.bindeval(vim_arg_list_name)
arg_list.extend(args)
arg_expr = ', '.join(['%s[%s]' %(vim_arg_list_name, i) for i in range(len(args))])
expr = '%s(%s)' % (funcname, arg_expr)
vim.eval(expr)
vc('unlet %s' % (vim_arg_list_name))
开发者ID:volkhin,项目名称:vimrc,代码行数:16,代码来源:fbvimutils.py
示例17: trailing_whitespace
def trailing_whitespace(pl, segment_info):
'''Return the line number for trailing whitespaces
It is advised not to use this segment in insert mode: in Insert mode it will
iterate over all lines in buffer each time you happen to type a character
which may cause lags. It will also show you whitespace warning each time you
happen to type space.
Highlight groups used: ``trailing_whitespace`` or ``warning``.
'''
global trailing_whitespace_cache
if trailing_whitespace_cache is None:
trailing_whitespace_cache = register_buffer_cache(defaultdict(lambda: (0, None)))
bufnr = segment_info['bufnr']
changedtick = getbufvar(bufnr, 'changedtick')
if trailing_whitespace_cache[bufnr][0] == changedtick:
return trailing_whitespace_cache[bufnr][1]
else:
buf = segment_info['buffer']
bws = b' \t'
sws = str(bws)
for i in range(len(buf)):
try:
line = buf[i]
except UnicodeDecodeError: # May happen in Python 3
if hasattr(vim, 'bindeval'):
line = vim.bindeval('getbufline({0}, {1})'.format(
bufnr, i + 1))
has_trailing_ws = (line[-1] in bws)
else:
line = vim.eval('strtrans(getbufline({0}, {1}))'.format(
bufnr, i + 1))
has_trailing_ws = (line[-1] in bws)
else:
has_trailing_ws = (line and line[-1] in sws)
if has_trailing_ws:
break
if has_trailing_ws:
ret = [{
'contents': str(i + 1),
'highlight_groups': ['trailing_whitespace', 'warning'],
}]
else:
ret = None
trailing_whitespace_cache[bufnr] = (changedtick, ret)
return ret
开发者ID:21gunnns,项目名称:powerline,代码行数:46,代码来源:__init__.py
示例18: rename
def rename(clang_service):
tu_ctx = clang_service.get_tu_ctx(vim.current.buffer.name)
if tu_ctx is None:
return
clang_service.update_unsaved_dict(__get_buffer_dict(), False)
clang_service.parse_all()
vim_cursor, def_cursor = clighter_helper.get_vim_cursor_and_def(tu_ctx)
if vim_cursor is None or def_cursor is None:
return
old_name = clighter_helper.get_spelling_or_displayname(def_cursor)
vim.command("echohl WildMenu")
new_name = vim.bindeval(
"input(' Rename {0} : ', '{1}')".format(old_name, old_name))
vim.command("echohl None")
if not new_name or old_name == new_name:
return
print ' '
pos = vim.current.window.cursor
locs = set()
locs.add((def_cursor.location.line, def_cursor.location.column,
def_cursor.location.file.name))
clighter_helper.search_ref_tokens(
tu_ctx.translation_unit,
def_cursor,
locs)
__vim_multi_replace(
locs,
old_name,
new_name,
vim.vars['clighter_rename_prompt_level'])
if clighter_helper.is_symbol_cursor(
def_cursor) and vim.vars['clighter_enable_cross_rename'] == 1:
__cross_buffer_rename(clang_service, def_cursor.get_usr(), new_name)
vim.current.window.cursor = pos
clang_service.update_unsaved_dict(__get_buffer_dict(), True)
开发者ID:borman,项目名称:clighter,代码行数:46,代码来源:refactor.py
示例19: setupWindow
def setupWindow(self):
# save current window
self.current_winnr = vim.bindeval('winnr()')
# setup our typeahead buffer
vc('botright 1new "File Search"',
'setlocal buftype=nofile',
'nohlsearch',
'setlocal noswapfile winfixheight',
'setlocal nocursorcolumn',
'setlocal nocursorline',
'setlocal nonumber',
'setlocal nowrap',
'setlocal bufhidden=wipe',
'resize %s' % (self.win_size),
'normal "10oggzt"'
)
开发者ID:volkhin,项目名称:vimrc,代码行数:17,代码来源:fbvimtypeahead.py
示例20: run_pytest
def run_pytest():
""" Main entry point
If current file is a test file, run it and store its name,
Otherwise, run the latest stored test.
"""
cur_filename = vim.current.buffer.name
if not cur_filename:
return
basename = os.path.basename(cur_filename)
if basename.startswith("test"):
to_run = cur_filename
else:
to_run = vim.bindeval("t:pytest_latest_test")
if not to_run:
return
vim.command("!py.test %s" % to_run)
vim.command('let t:pytest_latest_test="%s"' % to_run)
开发者ID:yannicklm,项目名称:vimpytest,代码行数:19,代码来源:run.py
注:本文中的vim.bindeval函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论