Skip to content

Commit

Permalink
Make whole-line markers configurable.
Browse files Browse the repository at this point in the history
Signed-off-by: Karolis Petrauskas <[email protected]>
  • Loading branch information
kape1395 authored and lemmy committed Oct 16, 2023
1 parent 606bf3c commit cf04d98
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 23 deletions.
17 changes: 11 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,11 @@
"items": {"type": "string"},
"description": "Command and arguments to start a TLAPS LSP server.",
"default": ["opam", "exec", "--", "tlapm_lsp", "--log-io", "--log-to=/tmp/tlapm_lsp.log"]
},
"tlaplus.tlaps.wholeLine": {
"type": "boolean",
"default": true,
"description": "Mark proof step states using whole line."
}
}
},
Expand Down Expand Up @@ -435,18 +440,18 @@
"id": "tlaplus.tlaps.proofState.omitted",
"description": "Background for a sequent with omitted proof.",
"defaults": {
"dark": "#c8ff0020",
"light": "#c8ff0020",
"highContrast": "#c8ff0050"
"dark": "#ff660020",
"light": "#ff660020",
"highContrast": "#ff660050"
}
},
{
"id": "tlaplus.tlaps.proofState.missing",
"description": "Background for a sequent with no proof.",
"defaults": {
"dark": "#c8ff0020",
"light": "#c8ff0020",
"highContrast": "#c8ff0050"
"dark": "#ff660020",
"light": "#ff660020",
"highContrast": "#ff660050"
}
},
{
Expand Down
43 changes: 26 additions & 17 deletions src/tlaps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export class TlapsClient {
private client: LanguageClient | undefined;
private configEnabled = false;
private configCommand = [] as string[];
private configWholeLine = true;
private proofStateNames = [
'proved',
'failed',
Expand All @@ -26,20 +27,7 @@ export class TlapsClient {
'pending',
'progress',
];
private proofStateDecorationTypes = new Map<string, vscode.TextEditorDecorationType>(
this.proofStateNames.map(name => {
const color = { 'id': 'tlaplus.tlaps.proofState.' + name };
const decType = vscode.window.createTextEditorDecorationType({
overviewRulerColor: color,
overviewRulerLane: vscode.OverviewRulerLane.Right,
light: { backgroundColor: color },
dark: { backgroundColor: color },
isWholeLine: true,
rangeBehavior: vscode.DecorationRangeBehavior.ClosedClosed,
});
return [name, decType];
})
);
private proofStateDecorationTypes = new Map<string, vscode.TextEditorDecorationType>();

constructor(private context: vscode.ExtensionContext) {
context.subscriptions.push(vscode.commands.registerTextEditorCommand(
Expand All @@ -63,13 +51,31 @@ export class TlapsClient {
context.subscriptions.push(vscode.workspace.onDidChangeConfiguration(event => {
if (this.readConfig()) {
this.tryStop();
this.makeDecoratorTypes();
this.tryStart();
}
}));
this.readConfig();
this.makeDecoratorTypes();
this.tryStart();
}

private makeDecoratorTypes() {
this.proofStateDecorationTypes.clear();
this.proofStateNames.forEach(name => {
const color = { 'id': 'tlaplus.tlaps.proofState.' + name };
const decType = vscode.window.createTextEditorDecorationType({
overviewRulerColor: color,
overviewRulerLane: vscode.OverviewRulerLane.Right,
light: { backgroundColor: color },
dark: { backgroundColor: color },
isWholeLine: this.configWholeLine,
rangeBehavior: vscode.DecorationRangeBehavior.ClosedOpen,
});
this.proofStateDecorationTypes.set(name, decType);
});
}

public deactivate() {
this.tryStop();
}
Expand All @@ -78,11 +84,14 @@ export class TlapsClient {
const config = vscode.workspace.getConfiguration();
const configEnabled = config.get<boolean>('tlaplus.tlaps.enabled');
const configCommand = config.get<string[]>('tlaplus.tlaps.lspServerCommand');
const configChanged =
configEnabled !== this.configEnabled ||
JSON.stringify(configCommand) !== JSON.stringify(this.configCommand);
const configWholeLine = config.get<boolean>('tlaplus.tlaps.wholeLine');
const configChanged = false
|| configEnabled !== this.configEnabled
|| JSON.stringify(configCommand) !== JSON.stringify(this.configCommand)
|| configWholeLine !== this.configWholeLine;
this.configEnabled = !!configEnabled;
this.configCommand = configCommand ? configCommand : [];
this.configWholeLine = !!configWholeLine;
return configChanged;
}

Expand Down

0 comments on commit cf04d98

Please sign in to comment.