本文整理汇总了Python中neovim.attach方法的典型用法代码示例。如果您正苦于以下问题:Python neovim.attach方法的具体用法?Python neovim.attach怎么用?Python neovim.attach使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类neovim
的用法示例。
在下文中一共展示了neovim.attach方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setup_neovim
# 需要导入模块: import neovim [as 别名]
# 或者: from neovim import attach [as 别名]
def setup_neovim(serveraddr):
logger.info("connecting to neovim server: %s",serveraddr)
# create another connection to avoid synchronization issue?
if len(serveraddr.split(':'))==2:
serveraddr,port = serveraddr.split(':')
port = int(port)
nvim = attach('tcp',address=serveraddr,port=port)
else:
nvim = attach('socket',path=serveraddr)
sync_rtp(nvim)
return nvim
示例2: Start
# 需要导入模块: import neovim [as 别名]
# 或者: from neovim import attach [as 别名]
def Start(self):
"""Starts Neovim"""
self.process = subprocess.Popen(self.start_command, env=self.env)
start_time = time.time()
# Wait at most 5s for the Neovim socket
while not os.path.exists(self.args.servername) \
and time.time() - start_time < 5:
time.sleep(0.01)
self.nvim = neovim.attach('socket', path=self.args.servername)
示例3: main
# 需要导入模块: import neovim [as 别名]
# 或者: from neovim import attach [as 别名]
def main(ctx, prog, notify, listen, connect, font, profile):
"""Entry point."""
address = connect or listen
setup_logging("gtk_ui")
if address:
import re
p = re.compile(r'^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}(?:\:\d{1,5})?$')
if p.match(address):
args = ('tcp',)
kwargs = {'address': address}
else:
args = ('socket',)
kwargs = {'path': address}
if connect:
# connect to existing instance listening on address
nvim = attach(*args, **kwargs)
elif listen:
# spawn detached instance listening on address and connect to it
import os
import time
from subprocess import Popen
os.environ['NVIM_LISTEN_ADDRESS'] = address
nvim_argv = shlex.split(prog or 'nvim --headless') + ctx.args
# spawn the nvim with stdio redirected to /dev/null.
dnull = open(os.devnull)
p = Popen(nvim_argv, stdin=dnull, stdout=dnull, stderr=dnull)
dnull.close()
while p.poll() or p.returncode is None:
try:
nvim = attach(*args, **kwargs)
break
except IOError:
# socket not ready yet
time.sleep(0.050)
else:
# spawn embedded instance
nvim_argv = shlex.split(prog or 'nvim --embed') + ctx.args
nvim = attach('child', argv=nvim_argv)
from .gtk_ui import GtkUI
ui = GtkUI(font)
bridge = UIBridge()
bridge.connect(nvim, ui, profile if profile != 'disable' else None, notify)
示例4: default_test
# 需要导入模块: import neovim [as 别名]
# 或者: from neovim import attach [as 别名]
def default_test(self):
'''testFileDetection
Tests all data files for type and compares the results to the current
stored results.
'''
# try embedding nvim in order to run the tests
# os.environ['NVIM_LISTEN_ADDRESS']=
# nvim = neovim.attach('child',
# argv=["/usr/bin/env", "nvim", "--embed"])
nvim = neovim.attach('socket', path='/var/folders/kt/yxsj572j6z18h6gq073_zvdr0000gn/T/nvim1jLDkU/0')
myplug = vim_pudb.NvimPudb(nvim)
tv = myplug.sgnname()
self.assertIsNotNone(tv)
myplug.set_sgnname('bogus')
self.assertEquals(myplug.sgnname(), 'bogus')
myplug.set_sgnname(tv)
tv = myplug.bpsymbol()
self.assertIsNotNone(tv)
myplug.set_bpsymbol('bogus')
self.assertEquals(myplug.bpsymbol(), 'bogus')
myplug.set_bpsymbol(tv)
tv = myplug.hlgroup()
self.assertIsNotNone(tv)
myplug.set_lgroup('bogus')
self.assertEquals(myplug.hlgroup(), 'bogus')
myplug.set_lgroup(tv)
tv = myplug.launcher()
self.assertIsNotNone(tv)
myplug.set_launcher('bogus')
self.assertEquals(myplug.launcher(), 'bogus')
myplug.set_launcher(tv)
tv = myplug.nvim_python()
self.assertIsNotNone(tv)
tv = myplug.nvim_python3()
self.assertIsNotNone(tv)
tv = myplug.entrypoint()
self.assertIsNotNone(tv)
myplug.set_entrypoint('bogus')
self.assertEquals(myplug.entrypoint(), 'bogus')
myplug.set_entrypoint(tv)
tv = myplug.cbname()
self.assertIsNotNone(tv)
# test setting the venv
myplug.set_curbuff_as_entrypoint_with_venv(
buffname='/Users/magregor/src/pudb.vim/test/test_plugin.py')
# stand-alone test execution