Skip to content

Commit

Permalink
Support LSP semantic tokens in vscode (#145)
Browse files Browse the repository at this point in the history
The rainbow semantic tokens are disabled by default.
See the added doc for details.

Follow-up #149
  • Loading branch information
Colibrow authored and MaskRay committed Feb 23, 2025
1 parent 6ab7a54 commit 416c5d1
Show file tree
Hide file tree
Showing 14 changed files with 1,797 additions and 49 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ See:

* [ccls/wiki/Home](https://github.com/MaskRay/ccls/wiki/Home)
* [ccls/wiki/Visual Studio Code](https://github.com/MaskRay/ccls/wiki/Visual-Studio-Code)
* [enable SemanticTokens Rainbow](doc/enable-rainbow-colors.md)
220 changes: 220 additions & 0 deletions doc/enable-rainbow-colors.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,220 @@
# Enable rainbow colors for C/C++/Objective-C/Objective-C++

Insert below codes to the users `settings.json`

```json
{
"ccls.highlight.rainbow": 10,
"editor.semanticHighlighting.enabled": true,
"editor.semanticTokenColorCustomizations": {
"enabled": true,
"rules": {
"class:c": { "foreground": "#e1afc3" },
"class:cpp": { "foreground": "#e1afc3" },
"class:objective-c": { "foreground": "#e1afc3" },
"class:objective-cpp": { "foreground": "#e1afc3" },

"constructor:c": { "foreground": "#e5b124" },
"constructor:cpp": { "foreground": "#e5b124" },
"constructor:objective-c": { "foreground": "#e5b124" },
"constructor:objective-cpp": { "foreground": "#e5b124" },

"enum:c": { "foreground": "#e1afc3" },
"enum:cpp": { "foreground": "#e1afc3" },
"enum:objective-c": { "foreground": "#e1afc3" },
"enum:objective-cpp": { "foreground": "#e1afc3" },

"enumMember:c": { "foreground": "#429921" },
"enumMember:cpp": { "foreground": "#429921" },
"enumMember:objective-c": { "foreground": "#429921" },
"enumMember:objective-cpp": { "foreground": "#429921" },

"field:c": { "foreground": "#429921" },
"field:cpp": { "foreground": "#429921" },
"field:objective-c": { "foreground": "#429921" },
"field:objective-cpp": { "foreground": "#429921" },

"function:c": { "foreground": "#e5b124" },
"function:cpp": { "foreground": "#e5b124" },
"function:objective-c": { "foreground": "#e5b124" },
"function:objective-cpp": { "foreground": "#e5b124" },

"method:c": { "foreground": "#e5b124" },
"method:cpp": { "foreground": "#e5b124" },
"method:objective-c": { "foreground": "#e5b124" },
"method:objective-cpp": { "foreground": "#e5b124" },

"parameter:c": { "foreground": "#e5b124" },
"parameter:cpp": { "foreground": "#e5b124" },
"parameter:objective-c": { "foreground": "#e5b124" },
"parameter:objective-cpp": { "foreground": "#e5b124" },

"struct:c": { "foreground": "#e1afc3" },
"struct:cpp": { "foreground": "#e1afc3" },
"struct:objective-c": { "foreground": "#e1afc3" },
"struct:objective-cpp": { "foreground": "#e1afc3" },

"typeAlias:c": { "foreground": "#e1afc3" },
"typeAlias:cpp": { "foreground": "#e1afc3" },
"typeAlias:objective-c": { "foreground": "#e1afc3" },
"typeAlias:objective-cpp": { "foreground": "#e1afc3" },

"typeParameter:c": { "foreground": "#e1afc3" },
"typeParameter:cpp": { "foreground": "#e1afc3" },
"typeParameter:objective-c": { "foreground": "#e1afc3" },
"typeParameter:objective-cpp": { "foreground": "#e1afc3" },

"variable:c": { "foreground": "#429921" },
"variable:cpp": { "foreground": "#429921" },
"variable:objective-c": { "foreground": "#429921" },
"variable:objective-cpp": { "foreground": "#429921" },

"*.static:c": { "fontStyle": "bold" },
"*.static:cpp": { "fontStyle": "bold" },
"*.static:objective-c": { "fontStyle": "bold" },
"*.static:objective-cpp": { "fontStyle": "bold" },

"*.classScope:c": { "fontStyle": "italic" },
"*.classScope:cpp": { "fontStyle": "italic" },
"*.classScope:objective-c": { "fontStyle": "italic" },
"*.classScope:objective-cpp": { "fontStyle": "italic" },

"*.namespaceScope:c": { "fontStyle": "bold underline" },
"*.namespaceScope:cpp": { "fontStyle": "bold underline" },
"*.namespaceScope:objective-c": { "fontStyle": "bold underline" },
"*.namespaceScope:objective-cpp": { "fontStyle": "bold underline" },

"class.id0": { "foreground": "#e1afc3" },
"class.id1": { "foreground": "#d533bb" },
"class.id2": { "foreground": "#9b677f" },
"class.id3": { "foreground": "#e350b6" },
"class.id4": { "foreground": "#a04360" },
"class.id5": { "foreground": "#dd82bc" },
"class.id6": { "foreground": "#de3864" },
"class.id7": { "foreground": "#ad3f87" },
"class.id8": { "foreground": "#dd7a90" },
"class.id9": { "foreground": "#e0438a" },

"constructor.id0:c": { "foreground": "#e5b124" },
"constructor.id1:c": { "foreground": "#927754" },
"constructor.id2:c": { "foreground": "#eb992c" },
"constructor.id3:c": { "foreground": "#e2bf8f" },
"constructor.id4:c": { "foreground": "#d67c17" },
"constructor.id5:c": { "foreground": "#88651e" },
"constructor.id6:c": { "foreground": "#e4b953" },
"constructor.id7:c": { "foreground": "#a36526" },
"constructor.id8:c": { "foreground": "#b28927" },
"constructor.id9:c": { "foreground": "#d69855" },

"enum.id0": { "foreground": "#e1afc3" },
"enum.id1": { "foreground": "#d533bb" },
"enum.id2": { "foreground": "#9b677f" },
"enum.id3": { "foreground": "#e350b6" },
"enum.id4": { "foreground": "#a04360" },
"enum.id5": { "foreground": "#dd82bc" },
"enum.id6": { "foreground": "#de3864" },
"enum.id7": { "foreground": "#ad3f87" },
"enum.id8": { "foreground": "#dd7a90" },
"enum.id9": { "foreground": "#e0438a" },

"enumMember.id0": { "foreground": "#429921" },
"enumMember.id1": { "foreground": "#58c1a4" },
"enumMember.id2": { "foreground": "#5ec648" },
"enumMember.id3": { "foreground": "#36815b" },
"enumMember.id4": { "foreground": "#83c65d" },
"enumMember.id5": { "foreground": "#419b2f" },
"enumMember.id6": { "foreground": "#43cc71" },
"enumMember.id7": { "foreground": "#7eb769" },
"enumMember.id8": { "foreground": "#58bf89" },
"enumMember.id9": { "foreground": "#3e9f4a" },

"field.id0": { "foreground": "#429921" },
"field.id1": { "foreground": "#58c1a4" },
"field.id2": { "foreground": "#5ec648" },
"field.id3": { "foreground": "#36815b" },
"field.id4": { "foreground": "#83c65d" },
"field.id5": { "foreground": "#419b2f" },
"field.id6": { "foreground": "#43cc71" },
"field.id7": { "foreground": "#7eb769" },
"field.id8": { "foreground": "#58bf89" },
"field.id9": { "foreground": "#3e9f4a" },

"function.id0": { "foreground": "#e5b124" },
"function.id1": { "foreground": "#927754" },
"function.id2": { "foreground": "#eb992c" },
"function.id3": { "foreground": "#e2bf8f" },
"function.id4": { "foreground": "#d67c17" },
"function.id5": { "foreground": "#88651e" },
"function.id6": { "foreground": "#e4b953" },
"function.id7": { "foreground": "#a36526" },
"function.id8": { "foreground": "#b28927" },
"function.id9": { "foreground": "#d69855" },

"method.id0": { "foreground": "#e5b124" },
"method.id1": { "foreground": "#927754" },
"method.id2": { "foreground": "#eb992c" },
"method.id3": { "foreground": "#e2bf8f" },
"method.id4": { "foreground": "#d67c17" },
"method.id5": { "foreground": "#88651e" },
"method.id6": { "foreground": "#e4b953" },
"method.id7": { "foreground": "#a36526" },
"method.id8": { "foreground": "#b28927" },
"method.id9": { "foreground": "#d69855" },

"parameter.id0": { "foreground": "#e5b124" },
"parameter.id1": { "foreground": "#927754" },
"parameter.id2": { "foreground": "#eb992c" },
"parameter.id3": { "foreground": "#e2bf8f" },
"parameter.id4": { "foreground": "#d67c17" },
"parameter.id5": { "foreground": "#88651e" },
"parameter.id6": { "foreground": "#e4b953" },
"parameter.id7": { "foreground": "#a36526" },
"parameter.id8": { "foreground": "#b28927" },
"parameter.id9": { "foreground": "#d69855" },

"struct.id0": { "foreground": "#e1afc3" },
"struct.id1": { "foreground": "#d533bb" },
"struct.id2": { "foreground": "#9b677f" },
"struct.id3": { "foreground": "#e350b6" },
"struct.id4": { "foreground": "#a04360" },
"struct.id5": { "foreground": "#dd82bc" },
"struct.id6": { "foreground": "#de3864" },
"struct.id7": { "foreground": "#ad3f87" },
"struct.id8": { "foreground": "#dd7a90" },
"struct.id9": { "foreground": "#e0438a" },

"typeAlias.id0": { "foreground": "#e1afc3" },
"typeAlias.id1": { "foreground": "#d533bb" },
"typeAlias.id2": { "foreground": "#9b677f" },
"typeAlias.id3": { "foreground": "#e350b6" },
"typeAlias.id4": { "foreground": "#a04360" },
"typeAlias.id5": { "foreground": "#dd82bc" },
"typeAlias.id6": { "foreground": "#de3864" },
"typeAlias.id7": { "foreground": "#ad3f87" },
"typeAlias.id8": { "foreground": "#dd7a90" },
"typeAlias.id9": { "foreground": "#e0438a" },

"typeParameter.id0": { "foreground": "#e1afc3" },
"typeParameter.id1": { "foreground": "#d533bb" },
"typeParameter.id2": { "foreground": "#9b677f" },
"typeParameter.id3": { "foreground": "#e350b6" },
"typeParameter.id4": { "foreground": "#a04360" },
"typeParameter.id5": { "foreground": "#dd82bc" },
"typeParameter.id6": { "foreground": "#de3864" },
"typeParameter.id7": { "foreground": "#ad3f87" },
"typeParameter.id8": { "foreground": "#dd7a90" },
"typeParameter.id9": { "foreground": "#e0438a" },

"variable.id0": { "foreground": "#429921" },
"variable.id1": { "foreground": "#58c1a4" },
"variable.id2": { "foreground": "#5ec648" },
"variable.id3": { "foreground": "#36815b" },
"variable.id4": { "foreground": "#83c65d" },
"variable.id5": { "foreground": "#419b2f" },
"variable.id6": { "foreground": "#43cc71" },
"variable.id7": { "foreground": "#7eb769" },
"variable.id8": { "foreground": "#58bf89" },
"variable.id9": { "foreground": "#3e9f4a" }
}
}
}
Loading

0 comments on commit 416c5d1

Please sign in to comment.