예제 #1
0
    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)
예제 #2
0
 def _jump_to(self, tag, mode=""):
     """To jump to the tag on the current line."""
     hidden = v.opt("hidden")
     autowriteall = v.opt("autowriteall")
     modified = v.call(u"getbufvar({},'&mod')".format(self.user_buf.nr))
     bufname = self.user_buf.name
     self._close()
     count, tagfile = self._tag_count(tag)
     if (not hidden and not autowriteall) and modified and tagfile != bufname:
         v.echohl(u"write the buffer first. (:h hidden)", "WarningMsg")
     else:
         v.exe(u"sil! {}{}tag {}".format(count, mode, tag["name"]))
         v.exe("normal! zvzzg^")
예제 #3
0
 def _open_window(self):
     """To open the Surfer window if not already visible."""
     if not self.winnr:
         self.exit_cmds.append(u"set ei={}".format(v.opt("ei")))
         v.exe(u"set eventignore=all")
         v.exe(u'sil! keepa botright 1new {}'.format(self.name))
         self._setup_buffer()
         self.winnr = v.bufwinnr(self.name)
예제 #4
0
    def setup_colors(self):
        """To setup Surfer highlight groups."""
        postfix = "" if v.opt("bg") == "light" else "_darkbg"
        colors = {
            "SurferShade": settings.get("shade_color{}".format(postfix)),
            "SurferMatches": settings.get("matches_color{}".format(postfix)),
            "SurferPrompt": settings.get("prompt_color{}".format(postfix)),
            "SurferError": "WarningMsg"
        }
        for group, color in colors.items():
            if color:
                link = "" if "=" in color else "link"
                v.exe(u"hi {} {} {}".format(link, group, color))

        colors = settings.get("visual_kinds_colors{}".format(postfix))
        for kind, color in colors.items():
            if color:
                link = "" if "=" in color else "link"
                v.exe(u"hi {} SurferVisualKind_{} {}".format(link, kind, color))