MaskRay / vscode-ccls

ccls plugin for Visual Studio Code
123 stars 37 forks source link

Redesign semantic highlight configurations #75

Closed MaskRay closed 5 years ago

MaskRay commented 5 years ago

We currently use a bunch of options to customize styles of various symbol kinds:

// enable semantic highlight for static member functions
"ccls.highlighting.enabled.staticMemberFunctions": true,
// styles
"ccls.highlighting.bold.staticMemberFunctions": true,
"ccls.highlighting.underline.staticMemberFunctions": true,
"ccls.highlighting.italic.staticMemberFunctions": true,

// similar options for other symbol kinds: memberFunctions, freeStandingFunctions, etc

This is tedious. This patch changes it to adopt the approach I used in emacs-ccls.

To enable semantic highlight, add the following lines to settings.json:

    "ccls.highlight.type.face": ["enabled"],
    "ccls.highlight.function.face": ["enabled"],
    "ccls.highlight.variable.face": ["enabled"],

function type and variable are considered basic symbol kinds. Other symbol kinds inherit styles (bold/italic/underline/etc) and colors from basic symbol kinds. For example, the default package.json specifies:

// Mix of function.face and member.face
"ccls.highlight.memberFunction.face": ["function", "member"]
"ccls.highlight.function.face": ["enabled"]
"ccls.highlight.member.face": ["fontStyle: italic"]
// Mix of variable.face and global.face
"ccls.highlight.globalVariable.face": ["variable", "global"]
"ccls.highlight.global.face": ["fontWeight: bolder"]

To fix the colors of some specific symbol kinds (say staticMemberFunction), specify:

 "ccls.highlighting.staticMemberFunctions.colors": [ "#0000c0" ],

to override ccls.highlighting.function.colors for static member functions.

Available symbol kinds:

  'function',
  'variable',
  'type',
  'enum',
  'globalVariable',
  'macro',
  'memberFunction',
  'memberVariable',
  'namespace',
  'parameter',
  'staticMemberFunction',
  'staticVariable',
  'typeAlias',