示例#1
0
def start_event_loop():
    global ticker

    if not bool(int(vim.eval('has("clientserver")'))):
        return fallback_to_feedkeys(
            "This VIM was not compiled with clientserver support. You should consider using a different vim!"
        )

    exe = getattr(G, 'VIM_EXECUTABLE', None)
    if not exe:
        return fallback_to_feedkeys(
            "Your vim was compiled with clientserver, but I don't know the name of the vim executable.  Please define it in your ~/.floorc using the vim_executable directive. e.g. 'vim_executable mvim'."
        )

    servername = vim.eval("v:servername")
    if not servername:
        return fallback_to_feedkeys(
            'I can not identify the servername of this vim. You may need to pass --servername to vim at startup.'
        )

    evaler = ticker_python.format(binary=exe,
                                  servername=servername,
                                  sleep='0.2')
    ticker = subprocess.Popen(['python', '-c', evaler],
                              stderr=subprocess.PIPE,
                              stdout=subprocess.PIPE)
    ticker.poll()
    sublime.set_timeout(ticker_watcher, 500, ticker)
示例#2
0
def is_modifiable(name_to_check=None):
    if not agent or not agent.protocol:
        return
    vim_buf = vim.current.buffer
    name = vim_buf.name
    if not name:
        return
    if name_to_check and name_to_check != name:
        msg.warn('Can not call readonly on file: %s' % name)
    if not agent.protocol.is_shared(name):
        return
    if 'patch' not in agent.protocol.perms:
        vim.command("call g:FlooSetReadOnly()")
        sublime.set_timeout(is_modifiable, 0, name)
示例#3
0
def ticker_watcher(ticker):
    global ticker_errors

    if not agent:
        return
    ticker.poll()
    if ticker.returncode is None:
        return
    msg.warn('respawning new ticker')
    ticker_errors += 1
    if ticker_errors > 10:
        return fallback_to_feedkeys('Too much trouble with the floobits external ticker.')
    start_event_loop()
    sublime.set_timeout(ticker_watcher, 2000, ticker)
示例#4
0
def is_modifiable(name_to_check=None):
    if not agent or not agent.protocol:
        return
    vim_buf = vim.current.buffer
    name = vim_buf.name
    if not name:
        return
    if name_to_check and name_to_check != name:
        msg.warn('Can not call readonly on file: %s' % name)
    if not agent.protocol.is_shared(name):
        return
    if 'patch' not in agent.protocol.perms:
        vim.command("call g:FlooSetReadOnly()")
        sublime.set_timeout(is_modifiable, 0, name)
示例#5
0
def ticker_watcher(ticker):
    global ticker_errors

    if not agent:
        return
    ticker.poll()
    if ticker.returncode is None:
        return
    msg.warn('respawning new ticker')
    ticker_errors += 1
    if ticker_errors > 10:
        return fallback_to_feedkeys('Too much trouble with the floobits external ticker.')
    start_event_loop()
    sublime.set_timeout(ticker_watcher, 2000, ticker)
示例#6
0
def start_event_loop():
    global ticker

    if not bool(int(vim.eval('has("clientserver")'))):
        return fallback_to_feedkeys("This VIM was not compiled with clientserver support. You should consider using a different vim!")

    exe = getattr(G, 'VIM_EXECUTABLE', None)
    if not exe:
        return fallback_to_feedkeys("Your vim was compiled with clientserver, but I don't know the name of the vim executable.  Please define it in your ~/.floorc using the vim_executable directive. e.g. 'vim_executable mvim'.")

    servername = vim.eval("v:servername")
    if not servername:
        return fallback_to_feedkeys('I can not identify the servername of this vim. You may need to pass --servername to vim at startup.')

    evaler = ticker_python.format(binary=exe, servername=servername, sleep='0.2')
    ticker = subprocess.Popen(['python', '-c', evaler],
                              stderr=subprocess.PIPE,
                              stdout=subprocess.PIPE)
    ticker.poll()
    sublime.set_timeout(ticker_watcher, 500, ticker)