Skip to main content

Module lsp

Module lsp 

Source
Expand description

Language intelligence (docs/design/lsp.md): opcodes, record codecs, and the client-side state/diagnostics mirror reducers. Language intelligence wire protocol (docs/design/lsp.md).

The server terminates LSP and projects it into blit-native records: per-backend phase/capabilities are pushed as whole-snapshot LSP_STATE messages ([LspStateMirror]), diagnostics are pushed as per-file replacement sets against a server-held cache ([LspDiagMirror]), and point-in-time answers are pulled through the single nonce-correlated LSP_QUERY opcode whose kind byte selects the operation.

Positions are 0-based lines with UTF-8 byte columns in both directions; the server transcodes to each backend’s negotiated encoding. All integers little-endian, tightly packed, as everywhere in the protocol.

Structs§

LspDiagMirror
The complete client obligation for LSP_DIAG: apply per-file replacement sets, ack. Absence of a path means unknown, not clean.
LspDiagRecordIter
LspDiagnostic
One diagnostic, owned, from a DIAG record.
LspFileDiags
One file’s diagnostic set.
LspOpened
A decoded S2C_LSP_OPENED.
LspQueryRecordIter
LspQueryRequest
A decoded C2S_LSP_QUERY request.
LspQueryResp
A decoded S2C_LSP_QUERY response.
LspServerState
One backend’s projected state, from a SERVER record.
LspServersRecordIter
LspStateMirror
The complete client obligation for LSP_STATE: replace the whole map, ack.
LspStateRecordIter

Enums§

LspDiagRecord
One decoded record from an LSP_DIAG payload.
LspQueryRecord
One decoded record from an LSP_QUERY response payload.
LspServersRecord
One decoded record from an LSP_SERVERS payload: the LSP_STATE SERVER layout plus the escaped workspace root.
LspStateRecord
One decoded record from an LSP_STATE payload.

Constants§

C2S_LSP_ACK
Acknowledge a pushed update: [0x62][lsp_id:2][stream:1][update_id:4] stream is LSP_STREAM_STATE or LSP_STREAM_DIAG.
C2S_LSP_BUFFER
Buffer overlay: [0x67][lsp_id:2][flags:1][path_len:2][path:N][text:LZ4] The full live buffer of an open editor (emitted-form path, like query paths); while overlaid, the engine’s byte source for the document is the overlay, not disk (docs/design/lsp.md “LSP_BUFFER”). Flags bit 0 LSP_BUFFER_RELEASE drops the overlay (text empty). No reply: idempotent last-writer-wins state on an ordered transport.
C2S_LSP_CANCEL
Advisory cancel of an in-flight query: [0x64][nonce:2]
C2S_LSP_CLOSE
Release an attachment (backends stay warm): [0x61][lsp_id:2]
C2S_LSP_OPEN
Attach to the workspace containing a path: [0x60][nonce:2][flags:1][diag_latency_ms:2][path_len:2][path:N] path is plain UTF-8 (client-chosen filesystem location, like FS_SYNC); the server walks upward for root markers.
C2S_LSP_QUERY
Point-in-time query: [0x63][nonce:2][lsp_id:2][kind:1][flags:1][line:4][col:4][path_len:2][path:N][arg_len:2][arg:N] kind is one of LSP_QUERY_*; line/col are ignored by the symbol kinds (for WS_SYMBOLS the line field is reserved as a future SymbolKind bitmask filter); arg carries the WS_SYMBOLS query string or the RENAME new name.
C2S_LSP_SERVERS
Enumerate every live backend, daemon-wide: [0x65][nonce:2]
C2S_LSP_STOP
Shut one backend down by server_ref: [0x66][nonce:2][server_ref:2] A later query respawns it; observability before force.
FEATURE_LSP
S2C_HELLO feature bit: server supports the LSP_* message family.
LSP_BUFFER_RELEASE
Drop the overlay and revert the document to disk truth (text must be empty).
LSP_CAP_COMPLETION
LSP_CAP_DEFINITION
LSP_CAP_DOC_SYMBOLS
LSP_CAP_HOVER
LSP_CAP_REFERENCES
LSP_CAP_RENAME
LSP_CAP_SIGNATURE
LSP_CAP_WS_SYMBOLS
LSP_CLOSED_BACKEND_FAILED
LSP_CLOSED_CLIENT_REQUEST
LSP_CLOSED_PERMISSION_LOST
LSP_CLOSED_RESOURCE_LIMIT
LSP_CLOSED_ROOT_GONE
LSP_COMPLETION_DEPRECATED
LSP_COMPLETION_PRESELECT
LSP_COMPLETION_SNIPPET
insert is LSP snippet syntax; a client without snippet UI degrades it to plain text.
LSP_DIAG_DEPRECATED
LSP_DIAG_FULL
The update carries complete workspace diagnostic state: drop everything, then apply. Every DIAGS subscribe begins with one (the cache replay), and the server may send one at any time instead of an incremental update.
LSP_DIAG_RECORD_DIAG
LSP_DIAG_RECORD_FILE
LSP_DIAG_UNNECESSARY
LSP_HASH_NONE
The all-zero hash: content version unknown.
LSP_ID_INVALID
lsp_id value reporting an open failure.
LSP_MARKUP_MARKDOWN
LSP_MARKUP_PLAIN
LSP_OPEN_DIAGS
Stream LSP_DIAG; implies WATCH.
LSP_OPEN_FROM_PTY
Resolve the workspace path from a pty’s live cwd: a trailing [src_pty_id:2] names a pty and the server joins path onto its cwd before the root-marker walk (docs/ide.md Decision 3).
LSP_OPEN_WATCH
Stream LSP_STATE.
LSP_PHASE_FAILED
LSP_PHASE_INDEXING
LSP_PHASE_INITIALIZING
LSP_PHASE_READY
LSP_PHASE_SPAWNING
LSP_PROGRESS_UNKNOWN
progress_pct value when the backend reports no percentage.
LSP_QUERY_COMPLETION
COMPLETION records; the response’s LSP_RESP_INCOMPLETE flag mirrors the server’s isIncomplete (retype should re-query).
LSP_QUERY_DEFINITION
LOCATION records.
LSP_QUERY_DOC_SYMBOLS
SYMBOL records, pre-order; line/col ignored.
LSP_QUERY_HOVER
→ one MARKUP record (plus an optional LOCATION for the range).
LSP_QUERY_RECORD_COMPLETION
LSP_QUERY_RECORD_EDIT
LSP_QUERY_RECORD_LOCATION
LSP_QUERY_RECORD_MARKUP
LSP_QUERY_RECORD_SIGNATURE
LSP_QUERY_RECORD_SYMBOL
LSP_QUERY_REFERENCES
LOCATION records; flags bit 0 LSP_REFS_INCLUDE_DECLARATION.
LSP_QUERY_RENAME
EDIT records; arg = new name. Data, never applied.
LSP_QUERY_SIGNATURE
SIGNATURE records, active signature first.
LSP_QUERY_WS_SYMBOLS
SYMBOL records; path empty, arg = query string.
LSP_REFS_INCLUDE_DECLARATION
REFERENCES: include the declaration itself.
LSP_RESP_INCOMPLETE
A RENAME plan dropped file operations it cannot project (create / rename / delete of whole files in a WorkspaceEdit): the returned EDIT records are the text edits only, so the plan is incomplete.
LSP_RESP_TRUNCATED
The entries budget was hit; records present are valid.
LSP_SEVERITY_ERROR
LSP_SEVERITY_HINT
LSP_SEVERITY_INFO
LSP_SEVERITY_WARNING
LSP_SIGNATURE_ACTIVE
The active signature (emitted first).
LSP_SIGNATURE_NO_PARAM
SIGNATURE.active_param value when no parameter is active.
LSP_STATE_RECORD_SERVER
LSP_STATUS_BUDGET
A budget was exhausted with no way to truncate.
LSP_STATUS_CANCELLED
Ended by LSP_CANCEL.
LSP_STATUS_INVALID
Malformed request (unknown flags, kind, or field combination).
LSP_STATUS_NOT_FOUND
Path, symbol, or backend does not exist; discovery failures name the missing binary in the detail field.
LSP_STATUS_OK
LSP_STATUS_OTHER
Diagnostic in the message’s detail field where it has one.
LSP_STATUS_PERMISSION
LSP_STATUS_TOO_LARGE
Over a size cap; truncation flags cover the paginatable cases.
LSP_STATUS_UNKNOWN_ID
lsp_id unknown or already closed.
LSP_STATUS_WARMING
The backing server has not finished initialize/indexing; retryable.
LSP_STATUS_WRONG_TYPE
The element cannot answer this query (e.g. rename on a non-symbol).
LSP_STREAM_DIAG
LSP_STREAM_STATE
LSP_SYMBOL_DEPRECATED
S2C_LSP_CLOSED
Attachment ended server-side: [0x64][lsp_id:2][reason:1]
S2C_LSP_DIAG
Diagnostics update: [0x62][lsp_id:2][update_id:4][flags:1][records:LZ4] Per-file replacement sets; bit 0 LSP_DIAG_FULL carries the complete workspace state (drop everything, then apply).
S2C_LSP_OPENED
Open outcome: [0x60][nonce:2][lsp_id:2][status:1][flags:1][root_len:2][root:N][detail_len:2][detail:N] On failure lsp_id = LSP_ID_INVALID and detail carries a diagnostic; on success root is the canonical workspace root, escaped.
S2C_LSP_QUERY
Query response: [0x63][nonce:2][status:1][flags:1][detail_len:2][detail:N][records:LZ4] detail is a human-readable failure reason (empty on success).
S2C_LSP_SERVERS
Backend enumeration: [0x65][nonce:2][status:1][flags:1][records:LZ4] SERVER records as in LSP_STATE plus the escaped root.
S2C_LSP_STATE
Whole-state snapshot: [0x61][lsp_id:2][state_id:4][flags:1][records:LZ4] One SERVER record per live backend of the attachment.
S2C_LSP_STOPPED
Stop outcome: [0x66][nonce:2][status:1]

Functions§

append_lsp_diag_record
Append one record to an uncompressed LSP_DIAG records buffer.
append_lsp_query_record
Append one record to an uncompressed LSP_QUERY response buffer.
append_lsp_servers_record
Append one record to an uncompressed LSP_SERVERS records buffer.
append_lsp_state_record
Append one record to an uncompressed LSP_STATE records buffer.
lsp_diag_records
Iterate records in an uncompressed LSP_DIAG payload.
lsp_open_rebase
Rebase a FROM_PTY C2S_LSP_OPEN onto a resolved cwd (join cwd/path, clear FROM_PTY), producing a plain path-based open the handler consumes unchanged. cwd None (source pty gone) keeps path verbatim.
lsp_open_src_pty
Extract the trailing src_pty_id from a FROM_PTY C2S_LSP_OPEN.
lsp_query_records
Iterate records in an uncompressed LSP_QUERY response payload.
lsp_servers_records
Iterate records in an uncompressed LSP_SERVERS payload.
lsp_state_records
Iterate records in an uncompressed LSP_STATE payload.
lsp_status_text
Human-readable name for an LSP_STATUS_* code.
msg_lsp_ack
msg_lsp_buffer
Build a C2S_LSP_BUFFER: text is the full buffer content, LZ4-compressed on the wire. A LSP_BUFFER_RELEASE must carry empty text.
msg_lsp_cancel
msg_lsp_close
msg_lsp_closed
msg_lsp_diag
msg_lsp_open
msg_lsp_open_from_pty
Build a C2S_LSP_OPEN whose workspace path the server resolves from a pty’s live cwd: sets LSP_OPEN_FROM_PTY and appends [src_pty_id:2] after the path (docs/ide.md Decision 3).
msg_lsp_opened
msg_lsp_query
msg_lsp_query_resp
msg_lsp_servers
msg_lsp_servers_resp
msg_lsp_state
msg_lsp_stop
msg_lsp_stopped
parse_lsp_ack
Parse C2S_LSP_ACK into (lsp_id, stream, update_id).
parse_lsp_buffer
Parse C2S_LSP_BUFFER into (lsp_id, flags, path, text) with the text decompressed.
parse_lsp_cancel
parse_lsp_close
parse_lsp_closed
Parse S2C_LSP_CLOSED into (lsp_id, reason).
parse_lsp_diag
Parse S2C_LSP_DIAG into (lsp_id, update_id, flags, records) with the records decompressed.
parse_lsp_open
Parse C2S_LSP_OPEN into (nonce, flags, diag_latency_ms, path).
parse_lsp_opened
parse_lsp_query
parse_lsp_query_resp
Parse S2C_LSP_QUERY with the records decompressed.
parse_lsp_servers
parse_lsp_servers_resp
Parse S2C_LSP_SERVERS into (nonce, status, flags, records) with the records decompressed.
parse_lsp_state
Parse S2C_LSP_STATE into (lsp_id, state_id, flags, records) with the records decompressed.
parse_lsp_stop
Parse C2S_LSP_STOP into (nonce, server_ref).
parse_lsp_stopped
Parse S2C_LSP_STOPPED into (nonce, status).

Type Aliases§

LspHash
BLAKE3 truncated to 128 bits, as in the fs family: the content version a record describes.