vscode-semantic-tokens
Small utility to get the semantic tokens of a VS Code document in a more nicer format.
This basically computes the semantic tokens you would get from DocumentSemanticTokensProvider.provideDocumentSemanticTokens method.
Usage
The API is fairly simple. You just need to pass a TextDocument
and you will get an array of semantic tokens.
import { getSemanticTokens } from 'vscode-semantic-tokens';
// ...
const tokens = getSemanticTokens(document);
The semantic tokens have the following shape:
export type SemanticToken = {
text: string;
line: number;
startChar: number;
length: number;
tokenType: string;
tokenModifiers: string[];
};