def _ex(vim: Nvim, word: str) -> None: # NOTE: # <C-b> (\x02) in a command-line move the caret to the beginning. # Somehow the key above works in 'input()' function as well. expr = vim.call('input', ':', ' %s\x02' % word, 'command') if expr: vim.command(expr)
def highlight(vim: Nvim, syntax_name: str) -> None: for syn in HIGHLIGHT_SYNTAX: conceal = "conceal " if syn.get("is_conceal") else "" containedin = syntax_name + ("_" + str(syn["in"]) if "in" in syn else "") vim.command( "syntax match {0}_{1} /{2}/ {3}contained containedin={4}".format( syntax_name, syn["name"], syn["re"], conceal, containedin)) if not syn.get("is_conceal"): vim.command("highlight default link {0}_{1} {2}".format( syntax_name, syn["name"], syn["link"]))
def _paste(vim: Nvim, word: str, command: str, regtype: str) -> None: if regtype == '': regtype = 'v' # Paste. old_reg = [vim.call('getreg', '"'), vim.call('getregtype', '"')] vim.call('setreg', '"', word, regtype) try: vim.command('normal! ""' + command) finally: vim.call('setreg', '"', old_reg[0], old_reg[1]) # Open folds vim.command('normal! zv')
def _yank(vim: Nvim, word: str) -> None: vim.call('setreg', '"', word, 'v') if vim.call('has', 'clipboard'): vim.call('setreg', vim.eval('v:register'), word, 'v')