def _setup_buffer(self): """To set sane options for the search results buffer.""" last_search = "" if v.eval("@/"): last_search = v.eval("@/").decode(v.encoding()).replace(u'"', u'\\"') self.exit_cmds.extend([ u"let @/=\"{}\"".format(last_search), u"set laststatus={}".format(v.opt("ls")), u"set guicursor={}".format(v.opt("gcr")), ]) commands = [ "let @/ = ''", "call clearmatches()" ] options = [ "buftype=nofile", "bufhidden=wipe", "nobuflisted", "noundofile", "nobackup", "noswapfile", "nowrap", "nonumber", "nolist", "textwidth=0", "colorcolumn=0", "laststatus=0", "norelativenumber", "nocursorcolumn", "nospell", "foldcolumn=0", "foldcolumn=0", "guicursor=a:hor5-Cursor-blinkwait100", ] if settings.get("cursorline", bool): options.append("cursorline") else: options.append("nocursorline") for opt in options: v.exe("try|setl {}|catch|endtry".format(opt)) for cmd in commands: v.exe(cmd)
def get(name, type=None): """To get the value of a vim variable.""" rawval = v.eval(prefix + name) if type is bool: return False if rawval == '0' else True elif type is int: return int(rawval) elif type is float: return float(rawval) elif isinstance(rawval, basestring): return rawval.decode(v.encoding()) else: return rawval