def _highlight(self, filename, lbegin=1, lend=-1):
        """internal highlight function"""
        _lbegin = lbegin
        _lend = self.vimh.line("$") if lend == -1 else lend

        buffer = self.__vim.current.buffer
        tu = self.ctx[filename]["tu"]

        self.profiler.start("_highlight")
        syn_group = syntax.get_highlight(tu, buffer.name, _lbegin, _lend)

        for hl_group in syn_group:
            for pos in syn_group[hl_group]:
                _row = pos[0] - 1
                col_start = pos[1] - 1
                col_end = col_start + pos[2]
                buffer.add_highlight(hl_group, _row, col_start, col_end,\
                        self.syntax_src_id, async=True)
        self.profiler.stop()
Exemple #2
0
    def _highlight(self, filename, lbegin=1, lend=-1):
        """internal highlight function"""
        _lbegin = lbegin
        _lend = util.get_lineno("$") if lend == -1 else lend

        buffer = self.__vim.current.buffer
        tu = self.ctx[filename]["tu"]

        self.profiler.start("_highlight")
        # syn_group = syntax.get_highlight(tu, buffer.name, _lbegin, _lend)
        syn_hl = syntax.get_highlight(tu, buffer.name, _lbegin, _lend)

        highlight_reqs = []
        highlight_reqs.append(["nvim_buf_clear_highlight", \
                               [buffer, self.syntax_src_id, lbegin, lend]])
        for item in syn_hl:
            hl_group = item[0]
            pos = item[1]
            _row = pos[0] - 1
            col_start = pos[1] - 1
            hl_size = pos[2]
            col_end = col_start + hl_size
            n_moreline = pos[3]
            highlight_reqs.append(["nvim_buf_add_highlight", [buffer, \
                self.syntax_src_id, hl_group, _row, col_start, col_end]])
            if n_moreline:
                next_row = _row + 1
                bytes_left = hl_size - len(buffer[_row][col_start:])
                while bytes_left > 0:
                    highlight_reqs.append(["nvim_buf_add_highlight", [buffer, \
                        self.syntax_src_id, hl_group, next_row, 0, bytes_left]])
                    bytes_left = bytes_left - len(
                        buffer[next_row]) - 1  # no trailing "\n"
                    next_row = next_row + 1

        retvals, errors = self.__vim.api.call_atomic(highlight_reqs)
        self.profiler.stop()
Exemple #3
0
    def _highlight(self, filename, lbegin=1, lend=-1):
        """internal highlight function"""
        _lbegin = lbegin
        _lend = self.vimh.line("$") if lend == -1 else lend

        buffer = self.__vim.current.buffer
        tu = self.ctx[filename]["tu"]

        self.profiler.start("_highlight")
        # syn_group = syntax.get_highlight(tu, buffer.name, _lbegin, _lend)
        syn_hl = syntax.get_highlight(tu, buffer.name, _lbegin, _lend)

        highlight_reqs = []
        highlight_reqs.append(["nvim_buf_clear_highlight", \
                               [buffer, self.syntax_src_id, lbegin, lend]])
        for item in syn_hl:
            hl_group = item[0]
            pos = item[1]
            _row = pos[0] - 1
            col_start = pos[1] - 1
            hl_size = pos[2]
            col_end = col_start + hl_size
            n_moreline = pos[3]
            highlight_reqs.append(["nvim_buf_add_highlight", [buffer, \
                self.syntax_src_id, hl_group, _row, col_start, col_end]])
            if n_moreline:
                next_row = _row + 1
                bytes_left = hl_size - len(buffer[_row][col_start:])
                while bytes_left > 0:
                    highlight_reqs.append(["nvim_buf_add_highlight", [buffer, \
                        self.syntax_src_id, hl_group, next_row, 0, bytes_left]])
                    bytes_left = bytes_left - len(buffer[next_row]) - 1 # no trailing "\n"
                    next_row = next_row + 1

        retvals, errors = self.__vim.api.call_atomic(highlight_reqs)
        self.profiler.stop()