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§
- LspDiag
Mirror - The complete client obligation for
LSP_DIAG: apply per-file replacement sets, ack. Absence of a path means unknown, not clean. - LspDiag
Record Iter - LspDiagnostic
- One diagnostic, owned, from a
DIAGrecord. - LspFile
Diags - One file’s diagnostic set.
- LspOpened
- A decoded
S2C_LSP_OPENED. - LspQuery
Record Iter - LspQuery
Request - A decoded
C2S_LSP_QUERYrequest. - LspQuery
Resp - A decoded
S2C_LSP_QUERYresponse. - LspServer
State - One backend’s projected state, from a
SERVERrecord. - LspServers
Record Iter - LspState
Mirror - The complete client obligation for
LSP_STATE: replace the whole map, ack. - LspState
Record Iter
Enums§
- LspDiag
Record - One decoded record from an
LSP_DIAGpayload. - LspQuery
Record - One decoded record from an
LSP_QUERYresponse payload. - LspServers
Record - One decoded record from an
LSP_SERVERSpayload: theLSP_STATESERVERlayout plus the escaped workspace root. - LspState
Record - One decoded record from an
LSP_STATEpayload.
Constants§
- C2S_
LSP_ ACK - Acknowledge a pushed update: [0x62][lsp_id:2][stream:1][update_id:4]
streamisLSP_STREAM_STATEorLSP_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_RELEASEdrops the overlay (textempty). 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]
pathis plain UTF-8 (client-chosen filesystem location, likeFS_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]
kindis one ofLSP_QUERY_*;line/colare ignored by the symbol kinds (forWS_SYMBOLSthelinefield is reserved as a future SymbolKind bitmask filter);argcarries theWS_SYMBOLSquery string or theRENAMEnew 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_HELLOfeature bit: server supports theLSP_*message family.- LSP_
BUFFER_ RELEASE - Drop the overlay and revert the document to disk truth (
textmust 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 insertis 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
DIAGSsubscribe 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_idvalue reporting an open failure.- LSP_
MARKUP_ MARKDOWN - LSP_
MARKUP_ PLAIN - LSP_
OPEN_ DIAGS - Stream
LSP_DIAG; impliesWATCH. - 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 joinspathonto 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_pctvalue when the backend reports no percentage.- LSP_
QUERY_ COMPLETION - →
COMPLETIONrecords; the response’sLSP_RESP_INCOMPLETEflag mirrors the server’sisIncomplete(retype should re-query). - LSP_
QUERY_ DEFINITION - →
LOCATIONrecords. - LSP_
QUERY_ DOC_ SYMBOLS - →
SYMBOLrecords, pre-order;line/colignored. - LSP_
QUERY_ HOVER - → one
MARKUPrecord (plus an optionalLOCATIONfor 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 - →
LOCATIONrecords; flags bit 0LSP_REFS_INCLUDE_DECLARATION. - LSP_
QUERY_ RENAME - →
EDITrecords;arg= new name. Data, never applied. - LSP_
QUERY_ SIGNATURE - →
SIGNATURErecords, active signature first. - LSP_
QUERY_ WS_ SYMBOLS - →
SYMBOLrecords;pathempty,arg= query string. - LSP_
REFS_ INCLUDE_ DECLARATION REFERENCES: include the declaration itself.- LSP_
RESP_ INCOMPLETE - A
RENAMEplan dropped file operations it cannot project (create / rename / delete of whole files in aWorkspaceEdit): the returnedEDITrecords 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_paramvalue 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_idunknown 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_FULLcarries 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_INVALIDanddetailcarries a diagnostic; on successrootis the canonical workspace root, escaped. - S2C_
LSP_ QUERY - Query response: [0x63][nonce:2][status:1][flags:1][detail_len:2][detail:N][records:LZ4]
detailis a human-readable failure reason (empty on success). - S2C_
LSP_ SERVERS - Backend enumeration: [0x65][nonce:2][status:1][flags:1][records:LZ4]
SERVERrecords as inLSP_STATEplus the escaped root. - S2C_
LSP_ STATE - Whole-state snapshot: [0x61][lsp_id:2][state_id:4][flags:1][records:LZ4]
One
SERVERrecord 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_DIAGrecords buffer. - append_
lsp_ query_ record - Append one record to an uncompressed
LSP_QUERYresponse buffer. - append_
lsp_ servers_ record - Append one record to an uncompressed
LSP_SERVERSrecords buffer. - append_
lsp_ state_ record - Append one record to an uncompressed
LSP_STATErecords buffer. - lsp_
diag_ records - Iterate records in an uncompressed
LSP_DIAGpayload. - lsp_
open_ rebase - Rebase a
FROM_PTYC2S_LSP_OPENonto a resolvedcwd(joincwd/path, clearFROM_PTY), producing a plain path-based open the handler consumes unchanged.cwdNone(source pty gone) keepspathverbatim. - lsp_
open_ src_ pty - Extract the trailing
src_pty_idfrom aFROM_PTYC2S_LSP_OPEN. - lsp_
query_ records - Iterate records in an uncompressed
LSP_QUERYresponse payload. - lsp_
servers_ records - Iterate records in an uncompressed
LSP_SERVERSpayload. - lsp_
state_ records - Iterate records in an uncompressed
LSP_STATEpayload. - lsp_
status_ text - Human-readable name for an
LSP_STATUS_*code. - msg_
lsp_ ack - msg_
lsp_ buffer - Build a
C2S_LSP_BUFFER:textis the full buffer content, LZ4-compressed on the wire. ALSP_BUFFER_RELEASEmust carry emptytext. - msg_
lsp_ cancel - msg_
lsp_ close - msg_
lsp_ closed - msg_
lsp_ diag - msg_
lsp_ open - msg_
lsp_ open_ from_ pty - Build a
C2S_LSP_OPENwhose workspace path the server resolves from a pty’s live cwd: setsLSP_OPEN_FROM_PTYand 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_ACKinto(lsp_id, stream, update_id). - parse_
lsp_ buffer - Parse
C2S_LSP_BUFFERinto(lsp_id, flags, path, text)with the text decompressed. - parse_
lsp_ cancel - parse_
lsp_ close - parse_
lsp_ closed - Parse
S2C_LSP_CLOSEDinto(lsp_id, reason). - parse_
lsp_ diag - Parse
S2C_LSP_DIAGinto(lsp_id, update_id, flags, records)with the records decompressed. - parse_
lsp_ open - Parse
C2S_LSP_OPENinto(nonce, flags, diag_latency_ms, path). - parse_
lsp_ opened - parse_
lsp_ query - parse_
lsp_ query_ resp - Parse
S2C_LSP_QUERYwith the records decompressed. - parse_
lsp_ servers - parse_
lsp_ servers_ resp - Parse
S2C_LSP_SERVERSinto(nonce, status, flags, records)with the records decompressed. - parse_
lsp_ state - Parse
S2C_LSP_STATEinto(lsp_id, state_id, flags, records)with the records decompressed. - parse_
lsp_ stop - Parse
C2S_LSP_STOPinto(nonce, server_ref). - parse_
lsp_ stopped - Parse
S2C_LSP_STOPPEDinto(nonce, status).
Type Aliases§
- LspHash
- BLAKE3 truncated to 128 bits, as in the fs family: the content version a record describes.