Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make color customizations apply for C variants only #148

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,400 changes: 1,398 additions & 2 deletions package-lock.json

Large diffs are not rendered by default.

166 changes: 165 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "C/C++/ObjC language server supporting cross references, hierarchies, completion and semantic highlight",
"author": "ccls-project",
"license": "MIT",
"version": "0.1.29",
"version": "0.1.31",
"publisher": "ccls-project",
"repository": {
"type": "git",
Expand Down Expand Up @@ -579,6 +579,13 @@
"default": true,
"description": "Whether to do spell checking on undefined symbol names when computing diagnostics."
},
"ccls.highlight.rainbow": {
"type": "number",
"default": 10,
"minimum": 0,
"maximum": 20,
"description": "Enable rainbow semantic tokens by assigning different colors to symbols. Value indicates number of colors (0 to disable)."
},
"ccls.highlight.blacklist": {
"type": [
"array",
Expand Down Expand Up @@ -707,6 +714,163 @@
"description": "When set, logs all LSP messages to specified WebSocket endpoint."
}
}
},
"configurationDefaults": {
"[c][cpp][objective-c][objective-cpp]": {
"editor.semanticHighlighting.enabled": true,
"editor.semanticTokenColorCustomizations": {
"enabled": true,
"rules": {
"class": { "foreground": "#e1afc3" },
"constructor": { "foreground": "#e5b124" },
"enum": { "foreground": "#e1afc3" },
"enumMember": { "foreground": "#429921" },
"field": { "foreground": "#429921" },
"function": { "foreground": "#e5b124" },
"method": { "foreground": "#e5b124" },
"parameter": { "foreground": "#e5b124" },
"struct": { "foreground": "#e1afc3" },
"typeAlias": { "foreground": "#e1afc3" },
"typeParameter": { "foreground": "#e1afc3" },
"variable": { "foreground": "#429921" },

"*.static": { "fontStyle": "bold" },
"*.classScope": { "fontStyle": "italic" },
"*.namespaceScope": { "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": { "foreground": "#e5b124" },
"constructor.id1": { "foreground": "#927754" },
"constructor.id2": { "foreground": "#eb992c" },
"constructor.id3": { "foreground": "#e2bf8f" },
"constructor.id4": { "foreground": "#d67c17" },
"constructor.id5": { "foreground": "#88651e" },
"constructor.id6": { "foreground": "#e4b953" },
"constructor.id7": { "foreground": "#a36526" },
"constructor.id8": { "foreground": "#b28927" },
"constructor.id9": { "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" }
}
}
}
}
}
2 changes: 1 addition & 1 deletion src/hierarchies/callHierarchy.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { commands, Position, TreeItem, Uri } from 'vscode';
import { LanguageClient } from 'vscode-languageclient/lib/main';
import { LanguageClient } from 'vscode-languageclient/node';
import { Icon, IHierarchyNode } from '../types';
import { resourcePath } from '../utils';
import { Hierarchy } from './hierarchy';
Expand Down
2 changes: 1 addition & 1 deletion src/hierarchies/hierarchy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
TreeItemCollapsibleState,
Uri
} from 'vscode';
import { Disposable, LanguageClient } from 'vscode-languageclient/lib/main';
import { Disposable, LanguageClient } from 'vscode-languageclient/node';
import { IHierarchyNode } from '../types';
import { disposeAll, setContext } from '../utils';

Expand Down
4 changes: 2 additions & 2 deletions src/hierarchies/inheritanceHierarchy.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Position, TreeItem, Uri } from 'vscode';
import { LanguageClient } from 'vscode-languageclient/lib/main';
import { LanguageClient } from 'vscode-languageclient/node';
import { IHierarchyNode } from '../types';
import { Hierarchy } from './hierarchy';

Expand Down Expand Up @@ -42,7 +42,7 @@ export class InheritanceHierarchyProvider extends Hierarchy<InheritanceHierarchy
qualified: false,
});
element.children = result.children;
result.children.map((c) => InheritanceHierarchySetWantsDerived(c, element.wantsDerived));
result.children.map((c: InheritanceHierarchyNode) => InheritanceHierarchySetWantsDerived(c, element.wantsDerived));
return result.children;
}

Expand Down
2 changes: 1 addition & 1 deletion src/hierarchies/memberHierarchy.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { commands, Position, TreeItem, Uri } from 'vscode';
import { LanguageClient } from 'vscode-languageclient/lib/main';
import { LanguageClient } from 'vscode-languageclient/node';
import { IHierarchyNode } from '../types';
import { Hierarchy } from './hierarchy';

Expand Down
2 changes: 1 addition & 1 deletion src/inactiveRegions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
window,
workspace
} from "vscode";
import { LanguageClient } from "vscode-languageclient";
import { LanguageClient } from "vscode-languageclient/node";
import { disposeAll, normalizeUri } from "./utils";

export class InactiveRegionsProvider implements Disposable {
Expand Down
58 changes: 29 additions & 29 deletions src/semantic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ interface SemanticSymbol {
readonly kind: SymbolKind|CclsSymbolKind;
readonly isTypeMember: boolean;
readonly storage: StorageClass;
readonly lsRanges: Range[];
// readonly lsRanges: Range[];
}

export interface PublishSemanticHighlightArgs {
Expand Down Expand Up @@ -85,34 +85,34 @@ export class SemanticContext implements Disposable {
disposeAll(this._dispose);
}

public publishSemanticHighlight(args: PublishSemanticHighlightArgs) {
const normUri = normalizeUri(args.uri);

for (const visibleEditor of window.visibleTextEditors) {
if (normUri !== visibleEditor.document.uri.toString(true))
continue;

const decorations = new Map<TextEditorDecorationType, Array<Range>>();

for (const symbol of args.symbols) {
const type = this.tryFindDecoration(symbol);
if (!type)
continue;
const existing = decorations.get(type);
if (existing) {
for (const range of symbol.lsRanges) {
existing.push(range);
}
} else {
decorations.set(type, symbol.lsRanges);
}
}

// TODO limit cache size
this.cachedDecorations.set(normUri, decorations);
this.updateDecoration(visibleEditor);
}
}
// public publishSemanticHighlight(args: PublishSemanticHighlightArgs) {
// const normUri = normalizeUri(args.uri);

// for (const visibleEditor of window.visibleTextEditors) {
// if (normUri !== visibleEditor.document.uri.toString(true))
// continue;

// const decorations = new Map<TextEditorDecorationType, Array<Range>>();

// for (const symbol of args.symbols) {
// const type = this.tryFindDecoration(symbol);
// if (!type)
// continue;
// const existing = decorations.get(type);
// if (existing) {
// for (const range of symbol.lsRanges) {
// existing.push(range);
// }
// } else {
// decorations.set(type, symbol.lsRanges);
// }
// }

// // TODO limit cache size
// this.cachedDecorations.set(normUri, decorations);
// this.updateDecoration(visibleEditor);
// }
// }

private updateConfigValues() {
const config = workspace.getConfiguration('ccls');
Expand Down
Loading