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

Fixing #1299 - Clojure LSP not starting when offline #1489

Merged
merged 1 commit into from
Jan 22, 2022
Merged
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 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Changes to Calva.

## [Unreleased]
- [Add custom commands from libraries](https://github.com/BetterThanTomorrow/calva/pull/1442)
- [Clojure-lsp not starting when offline](https://github.com/BetterThanTomorrow/calva/issues/1299)
- Workaround: [VS Code highlights characters in the output/REPL window prompt](https://github.com/BetterThanTomorrow/calva/pull/1475)

## [2.0.234] - 2022-01-16
Expand Down
11 changes: 8 additions & 3 deletions src/lsp/download.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,14 @@ import { https } from 'follow-redirects';
import * as extractZip from 'extract-zip';

async function getLatestVersion(): Promise<string> {
const releasesJSON = await util.fetchFromUrl('https://api.github.com/repos/clojure-lsp/clojure-lsp/releases');
const releases = JSON.parse(releasesJSON);
return releases[0].tag_name;
try {
const releasesJSON = await util.fetchFromUrl('https://api.github.com/repos/clojure-lsp/clojure-lsp/releases');
console.log("loaded latest Json" + releasesJSON);
const releases = JSON.parse(releasesJSON);
return releases[0].tag_name;
} catch (err) {
return "";
}
}

function getZipFileName(platform: string): string {
Expand Down
2 changes: 1 addition & 1 deletion src/lsp/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ async function activate(context: vscode.ExtensionContext, handler: TestTreeHandl
if (userConfiguredClojureLspPath === '') {
const configuredVersion: string = config.getConfig().clojureLspVersion;
const downloadVersion = ['', 'latest'].includes(configuredVersion) ? await getLatestVersion() : configuredVersion;
if (currentVersion !== downloadVersion) {
if (currentVersion !== downloadVersion && downloadVersion !== '') {
const downloadPromise = downloadClojureLsp(context.extensionPath, downloadVersion);
lspStatus.text = '$(sync~spin) Downloading clojure-lsp';
lspStatus.show();
Expand Down