CoqLspClient(LspClient) LspClient
Abstraction to interact with coq-lsp
file_progress : Dict[str, List[CoqFileProgressParams]] CoqFileProgressParams
Contains all the
$/coq/fileProgressnotifications sent by the server. The keys are the URIs of the files and the values are the list of notifications.
__completed_operation : threading.Event
Flag used to check if a pending operation has been completed. The flag is set when the LSP client sends the
textDocument/publishDiagnosticsrequest.
__init__(self, root_uri: str, timeout: int = 30, memory_limit: int = 2097152, coq_lsp: str = "coq-lsp", coq_lsp_options: Tuple[str] = None, init_options: Dict)Creates a CoqLspClient. After starting up the lsp in a new process, it initializes all objects used for communication with the server, then calls the initialization methods on the server.
root_uri : strURI to the workspace where coq-lsp will run The URI can be either a file or a folder.
timeout : int = 30Optional. Timeout used for the coq-lsp operations. Defaults to 2.
memory_limit : int = 2097152Optional. RAM limit for the coq-lsp process in kilobytes. It only works for Linux systems. Defaults to 2097152.
coq_lsp : str = "coq-lsp"Optional. Path to the coq-lsp binary. Defaults to "coq-lsp".
coq_lsp_options : Tuple[str] = NoneOptional. Options to be passed to the coq-lsp on startup. Defaults to None.
init_options : DictOptional. Initialization options for coq-lsp server. Available options are:
- max_errors (int): Maximum number of errors per file, after that, coq-lsp will stop checking the file. Defaults to 120000000.
- show_coq_info_messages (bool): Show Rocq's info messages as diagnostics. Defaults to false.
- show_notices_as_diagnostics (bool): Show Rocq's notice messages as diagnostics, such as
AboutandSearchoperations. Defaults to false.- debug (bool): Enable Debug in Rocq Server. Defaults to false.
- pp_type (int): Method to print Rocq Terms. 0 = Print to string. 1 = Use jsCoq's Pp rich layout printer. 2 = Rocq Layout Engine. Defaults to 1.
didOpen(self, textDocument: TextDocumentItem) -> NoneOpen a text document in the server and waits for the LSP to finish processing the file.
textDocument : TextDocumentItemTextDocumentItemText document to open.
didChange(self, textDocument: VersionedTextDocumentIdentifier, contentChanges: List[TextDocumentContentChangesEvent]) -> NoneSubmit changes on a text document already open on the server and waits for the LSP to finish processing the file.
textDocument : VersionedTextDocumentIdentifierVersionedTextDocumentIdentifierText document changed.
contentChanges : List[TextDocumentContentChangesEvent]TextDocumentContentChangeEventChanges made.
proof_goals(self, textDocument: TextDocumentIdentifier, position: Position) -> Optional[GoalAnswer]Get proof goals and relevant information at a position.
textDocument: TextDocumentIdentifierTextDocumentIdentiferText document to consider.
position : PositionPositionPosition used to get the proof goals.
Returns:
Optional[GoalAnswer]GoalAnswer Contains the goals at a position, messages associated to the position and if errors exist, the top error at the position.
get_document(self, textDocument: TextDocumentIdentifier) -> Optional[FlecheDocument]Get the AST of a text document.
textDocument : TextDocumentIdentifierTextDocumentIdentiferRequested text document.
Returns:
Optional[FlecheDocument]FlecheDocument Serialized version of Fleche's document.
save_vo(self, textDocument: TextDocumentIdentifier) -> NoneSave a compiled file to disk.
textDocument : TextDocumentIdentifierTextDocumentIdentiferFile to be saved. The uri in the textDocument should contain an absolute path.
__handle_publish_diagnostics(self, params: Dict) -> NoneCallback method used by the LspEndpoint to set the
__completed_operationflag to true when the endpoint receives thetextDocument/PublishDiagnosticsnotification.
params : DictUnused.
__handle_file_progress(self, params: Dict) -> NoneCallback method used by the LspEndpoint for when the endpoint receives the
$/coq/fileProgressnotification. When called, it modifies thefile_progresscollection according to
params : DictParameters passed from the LSP server containing information about file progress. Parsed into a CoqFileProgressParams object.
__wait_for_operation(self) -> NoneHelper method used to wait for the LSP server to send
textDocument/PublishDiagnosticsnotification. If the wait exceeds the endpoint's timeout, the Rocq LSP client is shutdown.Raises:
ResponseErrorResponseError: If the shutdown flag has been set, theServerQuiterror code is used. If the endpoint's timeout is exceeded, theServerTimeouterror code is used.