def getcurrentindent(buffer, linenumber: int) -> Tuple[int, bool]: # intentlevel, finishflag, unfinishedtype import afpython lines = [buffer[row] for row in range(linenumber)] return afpython.getpythonindent(lines)
import vim import sys sys.path.append(vim.eval("g:REPLVIM_PATH") + "autoload/") try: import afpython except Exception: import replpython as afpython codes = vim.eval("a:codes") newcodes = [] for i in range(len(codes)): if codes[i].lstrip().startswith("#"): indentlevel, finishflag, finishtype = afpython.getpythonindent(codes[:(i+1)]) if finishflag: continue newcodes.append(codes[i]) EOF return py3eval('newcodes') endfunction function! repl#RemoveExtraEmptyLine(lines, repl_program) python3 << EOF import vim def GetBlockType(codeblock): if not codeblock: return "EMPTY"
def analysepythonindent(self): self.codeindent = list() for i in range(len(self.rawcontents)): indentlevel, finishflag, finishtype = afpython.getpythonindent(self.rawcontents[:(i+1)]) self.codeindent.append((indentlevel, finishflag, finishtype))
def getcurrentindent(buffer, linenumber: int) -> Tuple[int, bool]: import afpython lines = [buffer[row] for row in range(linenumber)] return afpython.getpythonindent(lines)