本文整理汇总了Python中vim.bindeval函数的典型用法代码示例。如果您正苦于以下问题:Python bindeval函数的具体用法?Python bindeval怎么用?Python bindeval使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bindeval函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
示例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>'))
示例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]
示例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]
示例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'])
示例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)
示例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
示例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)
示例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
示例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()
示例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"))
示例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)
示例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
示例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)
示例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