euporie.core.lsp

Defines a simple LSP client.

Functions

NamedTuple(typename[, fields])

Typed version of namedtuple.

range_to_slice(start_line, start_char, ...)

Convert a line/character ranger to a slice.

Classes

Event(sender[, handler])

Simple event to which event handlers can be attached. For instance::.

LspCell(id, idx, path, kind, language, text, ...)

An LSP client's representation of a cell.

LspClient(name, command[, languages, settings])

A client for communicating with LSP servers.

Path(*args, **kwargs)

PurePath subclass that can make system calls.

class euporie.core.lsp.LspCell(id: str, idx: int, path: Path, kind: str, language: str, text: str, execution_count: int, metadata: dict[str, Any] | None = None)

Bases: NamedTuple

An LSP client’s representation of a cell.

count(value, /)

Return number of occurrences of value.

execution_count: int

Alias for field number 6

id: str

Alias for field number 0

idx: int

Alias for field number 1

index(value, start=0, stop=9223372036854775807, /)

Return first index of value.

Raises ValueError if the value is not present.

kind: str

Alias for field number 3

language: str

Alias for field number 4

metadata: dict[str, Any] | None

Alias for field number 7

path: Path

Alias for field number 2

text: str

Alias for field number 5

class euporie.core.lsp.LspClient(name: str, command: str, languages: Sequence[str] | None = None, settings: dict | None = None)

Bases: object

A client for communicating with LSP servers.

change_doc(path: Path, language: str, text: str, debounce: bool = True) None

Tell the server we have changed a document file.

change_nb_add(path: Path, cells: Sequence[LspCell]) None

Notify server of cells added to notebook.

change_nb_delete(path: Path, cells: Sequence[LspCell]) None

Notify server of cells removed from a notebook.

change_nb_edit(path: Path, cells: Sequence[LspCell], debounce: bool = True) None

Notify server of a change in notebook cells.

change_nb_meta(path: Path, metadata: dict[str, Any]) None

Notify server of a change in a notebook metadata.

close_doc(path: Path) None

Tell the server we have closed a document file.

close_nb(path: Path, cells: Sequence[LspCell]) None

Tell the server we closed a notebook document.

complete(path: Path, line: int, char: int, timeout: int = 5) list[dict[str, str]]

Trigger a LSP completion request.

async complete_(path: Path, line: int, char: int, timeout: int = 5) list[dict[str, Any]]

Request a completion from the LSP server.

diagnostics(params: dict[str, Any]) None

Receive a diagnstics report from the server.

exit() Future

Tell the server to exit.

async exit_(timeout: int = 1) None

Tell the server to exit.

format(path: Path, tab_size: int = 4, spaces: bool = True, timeout: int = 1) list[dict] | None

Request LSP document formatting.

async format_(path: Path, tab_size: int = 4, spaces: bool = True, timeout: int = 5) list[dict] | None

Trigger a formatting request from the LSP.

hover(path: Path, line: int, char: int, timeout: int = 1) dict

Trigger a LSP hover request.

async hover_(path: Path, line: int, char: int, timeout: int = 5) dict

Request hover text from the LSP server.

async initialize(root: Path | None = None) None

Initiate the LSP server.

log_message(params: dict[str, Any]) None

Send a log message from the server to the log.

loop = <_UnixSelectorEventLoop running=False closed=False debug=False>
property next_msg_id: int

Get and increment the RPC message ID.

open_doc(path: Path, language: str, text: str) None

Tell the server we have opened a document file.

open_nb(path: Path, cells: Sequence[LspCell], metadata: dict[str, Any] | None) None

Tell the server we have opened a notebook file.

async process_msg(data: dict) None

Process an incoming message from the LSP server.

save_doc(path: Path, text: str) None

Tell the server we saved a text document.

save_nb(path: Path) None

Tell the server we saved a notebook.

async send_msg(method: str, params: dict[str, Any] | None = None, cb: Callable[[Any], Coroutine[Any, Any, None]] | None = None) int

Send a message to the LSP server, returning the sent message’s ID.

signature(path: Path, line: int, char: int, timeout: int = 1) dict[str, object] | None

Trigger a LSP signature request.

async signature_(path: Path, line: int, char: int, timeout: int = 5) dict[str, object] | None

Request a signature from the LSP server.

start(root: Path | None = None) None

Start the LSP server.

async start_(root: Path | None = None) None

Launch the LSP server subprocess.

thread = <Thread(Thread-1 (_setup_loop), initial daemon)>
will_save_doc(path: Path) None

Tell the server we will save a document file.

will_save_nb(path: Path) None

Tell the server we will save a notebook file.

euporie.core.lsp.range_to_slice(start_line: int, start_char: int, end_line: int, end_char: int, text: str) slice

Convert a line/character ranger to a slice.