예제 #1
0
파일: help.py 프로젝트: ms-jpq/chadtree
def _help(nvim: Nvim, state: State, settings: Settings,
          args: Sequence[str]) -> None:
    """
    Open help doc
    """

    try:
        topic, use_web = _parse_args(args)
    except ArgparseError as e:
        write(nvim, e, error=True)
    else:
        md, uri = _directory(topic)
        web_d = open_w(uri) if use_web else False
        if not web_d:
            for win in list_floatwins(nvim):
                win_close(nvim, win=win)
            lines = md.read_text("UTF-8").splitlines()
            buf = create_buf(nvim,
                             listed=False,
                             scratch=True,
                             wipe=True,
                             nofile=True,
                             noswap=True)
            buf_set_lines(nvim, buf=buf, lo=0, hi=-1, lines=lines)
            buf_set_option(nvim, buf=buf, key="modifiable", val=False)
            buf_set_option(nvim, buf=buf, key="syntax", val="markdown")
            open_float_win(nvim,
                           margin=0,
                           relsize=0.95,
                           buf=buf,
                           border="rounded")
예제 #2
0
파일: terminal.py 프로젝트: hecjhs/nvim2
def toggle_floating(nvim: Nvim, *args: str) -> None:
    curr_win = cur_win(nvim)
    float_wins = frozenset(list_floatwins(nvim))
    if curr_win in float_wins:
        for win in float_wins:
            win_close(nvim, win=win)
    else:
        _term_open(nvim, *args)
예제 #3
0
def _kill_float_wins(nvim: Nvim, state: State, settings: Settings) -> None:
    try:
        wins = tuple(list_floatwins(nvim))
        if len(wins) != 2:
            for win in wins:
                win_close(nvim, win=win)
    except NvimError:
        pass
예제 #4
0
def open_term(nvim: Nvim, *args: AnyPath, opts: TermOpts = {}) -> None:
    argv = args or (environ["SHELL"],)
    prog, *_ = argv

    if not which(prog):
        write(nvim, LANG("invaild command: ", cmd=normcase(prog)), error=True)
    else:
        for win in list_floatwins(nvim):
            win_close(nvim, win=win)
        _term_open(nvim, *argv, opts=opts)
예제 #5
0
파일: stats.py 프로젝트: ms-jpq/coq-nvim
def stats(nvim: Nvim, stack: Stack, *_: str) -> None:
    stats = stack.idb.stats()
    chart1, chart2, chart3 = _pprn(stats)
    desc = MD_STATS.read_text()
    lines = (Template(_TPL).substitute(chart1=chart1,
                                       chart2=chart2,
                                       chart3=chart3,
                                       desc=desc).splitlines())
    for win in list_floatwins(nvim):
        win_close(nvim, win=win)
    buf = create_buf(nvim,
                     listed=False,
                     scratch=True,
                     wipe=True,
                     nofile=True,
                     noswap=True)
    buf_set_lines(nvim, buf=buf, lo=0, hi=-1, lines=lines)
    buf_set_option(nvim, buf=buf, key="modifiable", val=False)
    buf_set_option(nvim, buf=buf, key="syntax", val="markdown")
    open_float_win(nvim, margin=0, relsize=0.95, buf=buf, border="rounded")
예제 #6
0
파일: terminal.py 프로젝트: hecjhs/nvim2
def _kill_term_wins(nvim: Nvim) -> None:
    wins = tuple(list_floatwins(nvim))
    if len(wins) != 2:
        for win in wins:
            win_close(nvim, win=win)
예제 #7
0
파일: terminal.py 프로젝트: hecjhs/nvim2
def close_term(nvim: Nvim) -> None:
    for win in list_floatwins(nvim):
        win_close(nvim, win=win)
예제 #8
0
def _on_resized(nvim: Nvim) -> None:
    wins = tuple(list_floatwins(nvim))
    if wins:
        for win in wins:
            win_close(nvim, win=win)
        toggle_floating(nvim)