Example #1
0
    def __init__(self, handler: "CoqtailHandler") -> None:
        """Initialize variables.

        coqtop - The Coqtop interface
        handler - The Vim interface
        oldchange - The previous number of changes to the buffer
        oldbuf - The buffer corresponding to oldchange
        endpoints - A stack of the end positions of the sentences sent to Coqtop
                    (grows to the right)
        send_queue - A queue of the sentences to send to Coqtop
        error_at - The position of the last error
        info_msg - Lines of text to display in the info panel
        goal_msg - Lines of text to display in the goal panel
        goal_hls - Highlight positions for each line of goal_msg
        """
        self.coqtop = CT.Coqtop()
        self.handler = handler
        self.oldchange = 0
        self.oldbuf: List[bytes] = []
        self.endpoints: List[Tuple[int, int]] = []
        self.send_queue: Deque[Mapping[str, Tuple[int, int]]] = deque()
        self.error_at: Optional[Tuple[Tuple[int, int], Tuple[int, int]]] = None
        self.info_msg: List[str] = []
        self.goal_msg: List[str] = []
        self.goal_hls: List[Highlight] = []
Example #2
0
    def start(self, version, coq_path, *args):
        # type: (str, str, *str) -> None
        """Start a new Coqtop instance."""
        success = False
        errmsg = ["Failed to launch Coq"]

        def set_done():
            # type: () -> None
            """Callback to be triggered when Coqtop is done executing."""
            self.coqtop_done = True

        try:
            self.coqtop = CT.Coqtop(version, set_done)
            success = self.call_and_wait(
                self.coqtop.start, coq_path, *args, timeout=self.timeout
            )
        except (ValueError, CT.CoqtopError) as e:
            errmsg.append(str(e))

        if not success:
            print(". ".join(errmsg), file=sys.stderr)
Example #3
0
    def start(self, version, coq_path, coq_prog, args, opts):
        # type: (str, str, str, List[str], Mapping[str, Any]) -> Optional[Text]
        """Start a new Coqtop instance."""
        errmsg = []  # type: List[Text]

        try:
            self.coqtop = CT.Coqtop(version)
            err, stderr = self.coqtop.start(
                coq_path if coq_path != "" else None,
                coq_prog if coq_prog != "" else None,
                *args,
                timeout=opts["timeout"])
            if err is not None:
                errmsg.append(err)
            self.print_stderr(stderr)
        except (ValueError, CT.CoqtopError) as e:
            errmsg.append(str(e))

        if errmsg != []:
            return "Failed to launch Coq. " + ". ".join(errmsg)
        return None
Example #4
0
    def start(self, version, *args):
        # type: (Text, *Text) -> None
        """Start a new Coqtop instance."""
        success = False
        errmsg = ['Failed to launch Coq']

        def set_done():
            # type: () -> None
            """Callback to be triggered when Coqtop is done executing."""
            vim.current.buffer.vars['coqtop_done'] = 1

        try:
            self.coqtop = CT.Coqtop(version, set_done)
            success = self.call_and_wait(self.coqtop.start,
                                         *args,
                                         timeout=self.timeout)
        except ValueError as e:
            errmsg.append(str(e))

        if not success:
            print('. '.join(errmsg), file=sys.stderr)
Example #5
0
    def __init__(self, handler):
        # type: (CoqtailHandler) -> None
        """Initialize variables.

        coqtop - The Coqtop interface
        handler - The Vim interface
        oldchange - The previous number of changes to the buffer
        oldbuf - The buffer corresponding to oldchange
        endpoints - A stack of the end positions of the sentences sent to Coqtop
                    (grows to the right)
        send_queue - A queue of the sentences to send to Coqtop
        error_at - The position of the last error
        info_msg - The text to display in the info panel
        goal_msg - The text to display in the goal panel
        """
        self.coqtop = CT.Coqtop()
        self.handler = handler
        self.oldchange = 0
        self.oldbuf = []  # type: Sequence[Text]
        self.endpoints = []  # type: List[Tuple[int, int]]
        self.send_queue = deque()  # type: Deque[Mapping[str, Tuple[int, int]]]
        self.error_at = None  # type: Optional[Tuple[Tuple[int, int], Tuple[int, int]]]
        self.info_msg = []  # type: List[Text]
        self.goal_msg = []  # type: List[Text]