Exemplo n.º 1
0
 def clear_highlight(self,
                     src_id,
                     line_start=0,
                     line_end=-1,
                     async_=None,
                     **kwargs):
     """Clear highlights from the buffer."""
     async_ = check_async(async_, kwargs, True)
     self.request('nvim_buf_clear_highlight',
                  src_id,
                  line_start,
                  line_end,
                  async_=async_)
Exemplo n.º 2
0
 def add_highlight(self,
                   hl_group,
                   line,
                   col_start=0,
                   col_end=-1,
                   src_id=-1,
                   async_=None,
                   **kwargs):
     """Add a highlight to the buffer."""
     async_ = check_async(async_, kwargs, src_id != 0)
     return self.request('nvim_buf_add_highlight',
                         src_id,
                         hl_group,
                         line,
                         col_start,
                         col_end,
                         async_=async_)
Exemplo n.º 3
0
    def request(self, method, *args, **kwargs):
        """Send a msgpack-rpc request and block until as response is received.

        If the event loop is running, this method must have been called by a
        request or notification handler running on a greenlet. In that case,
        send the quest and yield to the parent greenlet until a response is
        available.

        When the event loop is not running, it will perform a blocking request
        like this:
        - Send the request
        - Run the loop until the response is available
        - Put requests/notifications received while waiting into a queue

        If the `async_` flag is present and True, a asynchronous notification
        is sent instead. This will never block, and the return value or error
        is ignored.
        """
        async_ = check_async(kwargs.pop('async_', None), kwargs, False)
        if async_:
            self._async_session.notify(method, args)
            return

        if kwargs:
            raise ValueError("request got unsupported keyword argument(s): {}"
                             .format(', '.join(kwargs.keys())))

        if self._is_running:
            v = self._yielding_request(method, args)
        else:
            v = self._blocking_request(method, args)
        if not v:
            # EOF
            raise OSError('EOF')
        err, rv = v
        if err:
            pass # replaces next logging statement
            #info("'Received error: %s", err)
            raise self.error_wrapper(err)
        return rv