Protocols
Saved & recent

LSP semantic tokens

Also called: semantic highlighting, semantic token legend

Semantic tokens let a language server describe the roles of pieces of source code, such as a variable, a function or a class. The editor maps those roles to its theme. This can distinguish names that look alike to a simple text scanner but have different meanings in the program.

In total = add(2, 3), a server might identify total as a variable and add as a function. LSP encodes token positions and refers to a server-declared legend of token types and modifiers. Supported delta updates can send changes to an earlier token result, reducing repeated data. The protocol describes meaning and positions; it does not prescribe the colors shown to the reader.

Read first
LSP initialization
Related
LSP initialization, LSP document synchronization, Language Server Protocol
Further reading
Microsoft — LSP 3.18 semantic tokens
total = add(2, 3) total add type index 0 · variable type index 1 · function example legend theme A theme B total add total add token changes optional delta update same roles · different colors
The server identifies semantic roles, and the editor chooses how its theme displays them.

View in the full Protocols collection