pub enum TokenKind {
Keyword,
Name,
Atom,
Number,
Str,
Comment,
Doc,
Punct,
}Expand description
What a run of source is, for the purpose of colouring it.
Deliberately small. A theme with thirty categories needs a grammar of its own to feed it; these eight are what the lexer already distinguishes, so every one of them is a fact rather than a guess.
Variants§
Keyword
A word the parser reads as syntax — beck_syntax::lexer::KEYWORDS, and nothing else.
Name
An identifier. Which ones are bound is a question for the checker, and an editor that coloured a name differently because it failed to resolve would be recolouring the file on every keystroke in the middle of a name.
Atom
:done — a keyword literal.
Number
Str
Comment
Doc
## — documentation, which is metadata rather than a comment (beck_syntax::doc).
Punct
Implementations§
Source§impl TokenKind
impl TokenKind
Sourcepub fn lsp_type(self) -> &'static str
pub fn lsp_type(self) -> &'static str
The LSP semantic-token type this maps to, from the protocol’s own list.
The mapping is here rather than in beck lsp so that an editor’s colours and the
playground’s are the same decision written once. ## is a comment to a client that has no
finer category for it, which is every client: the protocol has no documentation type.