Skip to content

Commit

Permalink
Merge pull request #721 from ejgallego/status_continuous
Browse files Browse the repository at this point in the history
[code] Display and allow status bar item to toggle continuous / lazy …
  • Loading branch information
ejgallego authored May 28, 2024
2 parents ae6ec4d + 809fb1a commit 7ba70bc
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@
user navigates proofs (@Alidra @ejgallego, #722, #725)
- `fcc`: new option `--diags_level` to control whether Coq's notice
and info messages appear as diagnostics
- Display the continous/on-request checking mode in the status bar,
allow to change it by clicking on it (@ejgallego, #721)

# coq-lsp 0.1.8.1: Spring fix
-----------------------------
Expand Down
31 changes: 24 additions & 7 deletions editor/code/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,19 +225,30 @@ export function activateCoqLSP(
.catch((error) => {
let emsg = error.toString();
console.log(`Error in coq-lsp start: ${emsg}`);
setFailedStatuBar(emsg);
setFailedStatusBar(emsg);
});
};

const restart = async () => {
await stop().finally(start);
};

const set_lazy_checking = async (value: boolean) => {
let wsConfig = workspace.getConfiguration();
await wsConfig.update("coq-lsp.check_only_on_request", value);
};

// switches between the different status of the server
const toggle = async () => {
if (client && client.isRunning()) {
if (client && client.isRunning() && !serverConfig.check_only_on_request) {
// Server on, and in continous mode, set lazy
await set_lazy_checking(true).then(updateStatusBar);
} else if (client && client.isRunning()) {
// Server on, and in lazy mode, stop
await stop();
} else {
await start();
// Server is off, set continous mode and start
await set_lazy_checking(false).then(start);
}
};

Expand Down Expand Up @@ -431,9 +442,15 @@ export function activateCoqLSP(
// We violate this on the error case, but only because it is exceptional.
const updateStatusBar = () => {
if (client && client.isRunning()) {
lspStatusItem.text = "$(check) coq-lsp (running)";
lspStatusItem.backgroundColor = undefined;
lspStatusItem.tooltip = "coq-lsp is running. Click to disable.";
if (serverConfig.check_only_on_request) {
lspStatusItem.text = "$(check) coq-lsp (on-demand checking)";
lspStatusItem.backgroundColor = undefined;
lspStatusItem.tooltip = "coq-lsp is running. Click to disable.";
} else {
lspStatusItem.text = "$(check) coq-lsp (continous checking)";
lspStatusItem.backgroundColor = undefined;
lspStatusItem.tooltip = "coq-lsp is running. Click to disable.";
}
} else {
lspStatusItem.text = "$(circle-slash) coq-lsp (stopped)";
lspStatusItem.backgroundColor = new ThemeColor(
Expand All @@ -443,7 +460,7 @@ export function activateCoqLSP(
}
};

const setFailedStatuBar = (emsg: string) => {
const setFailedStatusBar = (emsg: string) => {
lspStatusItem.text = "$(circle-slash) coq-lsp (failed to start)";
lspStatusItem.backgroundColor = new ThemeColor(
"statusBarItem.errorBackground"
Expand Down

0 comments on commit 7ba70bc

Please sign in to comment.