Skip to content

[I] Server

Language-server handlers and state for an embedding host to connect to LSP. Initialize the server before enabling document-update processing with Server.initialized.

PropertyModifierTypeDescription
pendingMessagesreadonlyreadonly ServerLog[]Messages queued before initialized; the queue is flushed through the host when logging resumes.
workspaceFoldersreadonlyreadonly ServerWorkspaceFolder[]Current workspace folders, including normalized paths used for project discovery.
buildSemanticTokens(params): Promise<SemanticTokens>;

Encode classified tokens as LSP semantic-token data using the legend advertised during initialization.

ParameterType
paramsSemanticTokensParams

Promise<SemanticTokens>


checkChange(change): void;

Schedule diagnostics for a changed document, ignoring the initial change notification accompanying an open.

ParameterType
changeTextDocumentChangeEvent<TextDocument>

void


compile(
document,
additionalOptions,
serverCompileOptions
): Promise<CompileResult | undefined>;

Compile the inferred project containing a document, falling back to the document itself if it is not included. Additional options override server defaults and resolved configuration. Returns undefined for unsupported documents, unresolved entry points, cancelled or stale requests, or handled compilation failures.

ParameterType
documentTextDocument | TextDocumentIdentifier
additionalOptionsCompilerOptions | undefined
serverCompileOptionsServerCompileOptions

Promise<CompileResult | undefined>


complete(params): Promise<CompletionList>;

Compute completion items at the requested position, including configuration-file completions.

ParameterType
paramsCompletionParams

Promise<CompletionList>


documentClosed(change): void;

Forget the document’s opening version and clear its published diagnostics.

ParameterType
changeTextDocumentChangeEvent<TextDocument>

void


documentOpened(change): void;

Record a document’s opening version and schedule its initial diagnostics.

ParameterType
changeTextDocumentChangeEvent<TextDocument>

void


findDocumentHighlight(params): Promise<DocumentHighlight[]>;

Find occurrences of the selected symbol within the requested document, marked as read highlights.

ParameterType
paramsDocumentHighlightParams

Promise<DocumentHighlight[]>


findReferences(params): Promise<Location[]>;

Find references to the selected symbol across the compiled program’s source files.

ParameterType
paramsReferenceParams

Promise<Location[]>


formatDocument(params): Promise<TextEdit[]>;

Format an open TypeSpec document using Prettier configuration, falling back to the client’s indentation options.

ParameterType
paramsDocumentFormattingParams

Promise<TextEdit[]>


getCodeActions(params): Promise<CodeAction[]>;

Offer unresolved quick fixes for published diagnostics, including file-wide fixes when applicable.

ParameterType
paramsCodeActionParams

Promise<CodeAction[]>


getDocumentSymbols(params): Promise<DocumentSymbol[]>;

Build the hierarchical symbol outline for a TypeSpec document.

ParameterType
paramsDocumentSymbolParams

Promise<DocumentSymbol[]>


getFoldingRanges(getFoldingRanges): Promise<FoldingRange[]>;

Compute multiline folding regions for comments, consecutive imports, decorators, and syntax nodes.

ParameterType
getFoldingRangesFoldingRangeParams

Promise<FoldingRange[]>


getHover(params): Promise<Hover>;

Describe the symbol at the requested position; return empty contents when no description is available.

ParameterType
paramsHoverParams

Promise<Hover>


getInitProjectContext(): Promise<InitProjectContext>;

Load the built-in project templates used by the editor’s project-creation workflow.

Promise<InitProjectContext>


getSemanticTokens(params): Promise<SemanticToken[]>;

Classify TypeSpec source into tokens with absolute source offsets rather than LSP-encoded positions.

ParameterType
paramsSemanticTokensParams

Promise<SemanticToken[]>


getSignatureHelp(params): Promise<SignatureHelp | undefined>;

Return debounced template or decorator signature help, or undefined for superseded requests or unsupported positions.

ParameterType
paramsSignatureHelpParams

Promise<SignatureHelp | undefined>


gotoDefinition(params): Promise<Location[]>;

Resolve a symbol’s declarations or an import’s target file. Returns an empty list when document analysis is unavailable or the position has no definition. Import lookup requires a resolvable target and rejects if module resolution fails.

ParameterType
paramsDefinitionParams

Promise<Location[]>


initialize(params): Promise<InitializeResult<any>>;

Configure workspace roots and update callbacks, and return LSP and TypeSpec-specific capabilities.

ParameterType
paramsInitializeParams

Promise<InitializeResult<any>>


initialized(params): void;

Enable debounced updates and flush queued log messages after client initialization completes.

ParameterType
paramsInitializedParams

void


initProject(param): Promise<boolean>;

Scaffold a project using the supplied configuration; log unexpected failures and return false on failure.

ParameterTypeDescription
param{ config: ScaffoldingConfig; }-
param.configScaffoldingConfigResolved project location, template, and user inputs used for scaffolding.

Promise<boolean>


internalCompile(param): Promise<InternalCompileResult>;

Run a full compilation without reusing cached compilations or old programs, forwarding captured compiler logs to the host.

ParameterTypeDescription
param{ doc: TextDocumentIdentifier; options: CompilerOptions; }-
param.docTextDocumentIdentifierDocument used to infer the project to compile.
param.optionsCompilerOptionsCompiler options overriding the resolved project and server defaults.

Promise<InternalCompileResult>


log(log): void;

Queue a message before initialized; afterwards flush queued messages and deliver it to the host.

ParameterType
logServerLog

void


prepareRename(params): Promise<Range | undefined>;

Return the selected identifier’s rename range, or undefined when no identifier can be renamed.

ParameterType
paramsPrepareRenameParams

Promise<Range | undefined>


rename(params): Promise<WorkspaceEdit>;

Build edits renaming references to the selected identifier; applying them is the caller’s responsibility.

ParameterType
paramsRenameParams

Promise<WorkspaceEdit>


renameFiles(params): Promise<void>;

Process renamed files or folders, schedule recompilation, and ask the host to apply import-path repairs.

ParameterType
paramsRenameFilesParams

Promise<void>


reportDiagnostics(__namedParameters): void;

Publish diagnostics for the result’s open documents and clear stale diagnostics for files without errors. Does nothing when the result has no open document or that document is tspconfig.yaml.

ParameterType
__namedParametersCompileResult

void


resolveCodeAction(codeAction): Promise<CodeAction>;

Populate a previously offered code action’s edit from the current diagnostic index.

ParameterType
codeActionCodeAction

Promise<CodeAction>


validateInitProjectTemplate(param): Promise<boolean>;

Validate a project template against the relaxed template schema, logging any validation diagnostics.

ParameterTypeDescription
param{ template: InitTemplate; }-
param.templateInitTemplateTemplate definition selected or supplied by the client.

Promise<boolean>


watchedFilesChanged(params): void;

Invalidate file and package caches for the client’s watched-file change notifications.

ParameterType
paramsDidChangeWatchedFilesParams

void


workspaceFoldersChanged(e): Promise<void>;

Apply added and removed workspace folders, resolving normalized paths for newly added roots.

ParameterType
eWorkspaceFoldersChangeEvent

Promise<void>