Although MS calls it "semantic" tokens, it seems to also include simple syntax things like keywords, numbers, strings, comments etc so it can provide the information to completely replace the lexer.

I think they are just trying to be generic enough for the purpose of the definition of the protocol in case some server provides such tokens, but in reality, not all of them have to be provided by the server. For instance, clangd doesn't provide keywords, numbers, or strings; pylsp doesn't support semantic tokens at all.

During the initialize() call the client announces its capabilities and, in return, the server sends back the features it supports. For clangd it looks this way:

{
  "capabilities" : {
    "astProvider" : true,
    "callHierarchyProvider" : true,
    "clangdInlayHintsProvider" : true,
    "codeActionProvider" : true,
    "compilationDatabase" : {
      "automaticReload" : true
    },
    "completionProvider" : {
      "allCommitCharacters" : [
        " ",
        "\t",
        "(",
        ")",
        "[",
        "]",
        "{",
        "}",
        "<",
        ">",
        ":",
        ";",
        ",",
        "+",
        "-",
        "/",
        "*",
        "%",
        "^",
        "&",
        "#",
        "?",
        ".",
        "=",
        "\"",
        "'",
        "|"
      ],
      "resolveProvider" : false,
      "triggerCharacters" : [
        ".",
        "<",
        ">",
        ":",
        "\"",
        "/",
        "*"
      ]
    },
    "declarationProvider" : true,
    "definitionProvider" : true,
    "documentFormattingProvider" : true,
    "documentHighlightProvider" : true,
    "documentLinkProvider" : {
      "resolveProvider" : false
    },
    "documentOnTypeFormattingProvider" : {
      "firstTriggerCharacter" : "\n",
      "moreTriggerCharacter" : []
    },
    "documentRangeFormattingProvider" : true,
    "documentSymbolProvider" : true,
    "executeCommandProvider" : {
      "commands" : [
        "clangd.applyFix",
        "clangd.applyTweak"
      ]
    },
    "hoverProvider" : true,
    "implementationProvider" : true,
    "memoryUsageProvider" : true,
    "referencesProvider" : true,
    "renameProvider" : true,
    "selectionRangeProvider" : true,
    "semanticTokensProvider" : {
      "full" : {
        "delta" : true
      },
      "legend" : {
        "tokenModifiers" : [
          "declaration",
          "deprecated",
          "deduced",
          "readonly",
          "static",
          "abstract",
          "virtual",
          "dependentName",
          "defaultLibrary",
          "usedAsMutableReference",
          "functionScope",
          "classScope",
          "fileScope",
          "globalScope"
        ],
        "tokenTypes" : [
          "variable",
          "variable",
          "parameter",
          "function",
          "method",
          "function",
          "property",
          "variable",
          "class",
          "interface",
          "enum",
          "enumMember",
          "type",
          "type",
          "unknown",
          "namespace",
          "typeParameter",
          "concept",
          "type",
          "macro",
          "comment"
        ]
      },
      "range" : false
    },
    "signatureHelpProvider" : {
      "triggerCharacters" : [
        "(",
        ")",
        "{",
        "}",
        "<",
        ">",
        ","
      ]
    },
    "textDocumentSync" : {
      "change" : 2,
      "openClose" : true,
      "save" : true
    },
    "typeDefinitionProvider" : true,
    "typeHierarchyProvider" : true,
    "workspaceSymbolProvider" : true
  },
  "serverInfo" : {
    "name" : "clangd",
    "version" : "Debian clangd version 14.0.6 linux+grpc aarch64-unknown-linux-gnu"
  }
}


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <geany/geany/pull/3571/c1752008207@github.com>