[PATCH] D87669: Rainbow Semantic Highlighting

Alex Zielenski via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 14 21:43:27 PDT 2020


alexzielenski created this revision.
alexzielenski added reviewers: MaskRay, ilya-biryukov, sammccall.
alexzielenski created this object with visibility "All Users".
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, jkorous.
Herald added a project: clang.
alexzielenski requested review of this revision.

This patch adds support for rainbow semantic highlighting seem in ccls and cquery into clangd's implementation of SemanticTokensProvider. The method of implementation is to create new modifiers "0, 1, 2, 4", which are pinned to the hash of a SymbolID, to be used by the user in the creation of their theme for rainbow highlighting.

This patch has a few flaws as well as minor improvements to clangd's classification of symbols and takes you 80% of the way. I mainly created it for my own purposes since I cannot read code without this feature. Hopefully you can merge something like this upstream so I don't have to keep maintaining my local checkout.

I attached an example of what this looks like, and below is the configuration I used in my VSCode settings so you can try for yourself:
F12954809: Screen Shot 2020-09-14 at 9.38.54 PM.png <https://reviews.llvm.org/F12954809>

  json
      "editor.semanticTokenColorCustomizations": {
          "enabled": true,
          "rules": {
              "variable:cpp": "#92d7f2",
              "variable.1:cpp": "#78a8d5",
              "variable.2:cpp": "#9be0e6",
              "variable.3:cpp": "#9cc2f7",
              "variable.4:cpp": "#5ba9b8",
              "variable.local:cpp": "#99bfcb",
              "variable.local.1:cpp": "#c2e9f5",
              "variable.local.2:cpp": "#add4e0",
              "variable.local.3:cpp": "#99bfcb",
              "variable.local.4:cpp": "#81afc5",
              "variable.member:cpp": "#4fbbbc",
              "variable.member.1:cpp": "#3ba7e5",
              "variable.member.2:cpp": "#33d4d1",
              "variable.member.3:cpp": "#4eb4f3",
              "variable.member.4:cpp": "#6ed7d8",
              "variable.static.member:cpp": "#66d4f6",
              "variable.static.member.1:cpp": "#2f8fa5",
              "variable.static.member.2:cpp": "#4ee2f4",
              "variable.static.member.3:cpp": "#88aee1",
              "variable.static.member.4:cpp": "#4ab9ce",
              "parameter:cpp": "#a4beb8",
              "parameter.1:cpp": "#7fd6c5",
              "parameter.2:cpp": "#b8d3cd",
              "parameter.3:cpp": "#9fcaac",
              "parameter.4:cpp": "#a8dfd4",
              "function:cpp": "#61cca5",
              "function.1:cpp": "#1fe1fb",
              "function.2:cpp": "#43c88b",
              "function.3:cpp": "#3edbd8",
              "function.4:cpp": "#63e5a6",
              "function.member:cpp": "#4bd6fd",
              "function.member.1:cpp": "#28e6cc",
              "function.member.2:cpp": "#4eb4f3",
              "function.member.3:cpp": "#4cccb7",
              "function.member.4:cpp": "#4abfe8",
              "function.static:cpp": "#9fa8e1",
              "function.static.1:cpp": "#20d8fd",
              "function.static.2:cpp": "#9ca6f4",
              "function.static.3:cpp": "#5bcdf6",
              "function.static.4:cpp": "#b4bcf7",
              "type:cpp": "#edc158",
              "type.1:cpp": "#f67b3e",
              "type.2:cpp": "#ecc02b",
              "type.3:cpp": "#e59668",
              "type.4:cpp": "#e6a01e",
              "enum:cpp": "#d55bc0",
              "enum.1:cpp": "#ee4d69",
              "enum.2:cpp": "#f570d9",
              "enum.3:cpp": "#f7457c",
              "enum.4:cpp": "#e44cc0",
              "enumConstant:cpp": "#f53d8b",
              "enumConstant.1:cpp": "#f53d8b",
              "enumConstant.2:cpp": "#ef489e",
              "enumConstant.3:cpp": "#d452a8",
              "enumConstant.4:cpp": "#d452a8",
              "macro:cpp": "#a85e16",
              "macro.1:cpp": "#d29e3b",
              "macro.2:cpp": "#8d630a",
              "macro.3:cpp": "#dc803d",
              "macro.4:cpp": "#dd9549",
              "namespace:cpp": "#c6a94d",
              "namespace.1:cpp": "#8c6a25",
              "namespace.2:cpp": "#daca74",
              "namespace.3:cpp": "#ab722f",
              "namespace.4:cpp": "#a19435"
          }
      }




Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87669

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/SemanticHighlighting.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D87669.291774.patch
Type: text/x-patch
Size: 7434 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200915/da2bb006/attachment.bin>


More information about the cfe-commits mailing list