Skip to content

The semantic tokens file view provider is unsure whether a keyword token is an identifier #2346

Done

Description

@lagergren

The semantic tokens file view provider can't tell whether a token of the standard type keyword is an identifier, or a type. It answers "unsure" for both.

What happens

LSPSemanticToken classifies a token through a few sets of token types:

  • ALL_TOKEN_TYPES lists the standard types and LSP4IJ's custom ones, but not keyword.
  • KEYWORD_TOKEN_TYPES has keyword and modifier.
  • NON_IDENTIFIER_TOKEN_TYPES and NON_TYPE_TOKEN_TYPES are ALL_TOKEN_TYPES minus the identifier and type sets.

So isIdentifier() and isType() of a keyword token are UNSURE. For modifier, which is in ALL_TOKEN_TYPES, both are NO.

Effect

From reading the code, not checked live: LSPSemanticTokenDocumentationProvider asks the language server for a token's hover documentation only when the token is an identifier, or is surely not one and isn't whitespace. So Quick Documentation on a keyword, in a file of the semantic tokens file view provider (a TextMate or plain-text file), doesn't ask the language server. rust-analyzer, for one, documents its keywords.

How it was found

The test of #2338 that checks that a custom token type is classified as its super type, LSPSemanticTokenCustomTypesTest, has to skip the answers that keyword leaves unsure.

Fix

Add SemanticTokenTypes.Keyword to ALL_TOKEN_TYPES, with a test of the classification and of the documentation of a keyword.

Activity

  1. added
    bug
    on Nov 28, 2026
  2. added this to the 0.30.3 milestone on Nov 28, 2026
  3. added a commit that references this issue on Nov 30, 2026
    c709e18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugsemantic tokens

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions