Skip to content

Commit

Permalink
Unify LS searching logic whether it is scarb project or not.
Browse files Browse the repository at this point in the history
Currently depending on if `Scarb.toml` was detected precedence of LS binary from settings ot from scarb is changing, remove this behaviour if favour of more stable one.
This is making usage of `cairo1.languageServerPath` and `cairo1.preferScarbLanguageServer` more predictable because it will work same way in scarb and non scarb projects.

commit-id:880ce024
  • Loading branch information
Draggu committed Jan 20, 2025
1 parent 8a799ff commit 72e02c1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 55 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
"cairo1.preferScarbLanguageServer": {
"type": "boolean",
"default": "true",
"markdownDescription": "If the workspace contains a Scarb.toml file, prefer using `scarb cairo-language-server` over standalone `cairo-language-server` (e.g. one specified by `cairo1.languageServerPath`).",
"markdownDescription": "Prefer using `scarb cairo-language-server` over standalone `cairo-language-server` (e.g. one specified by `cairo1.languageServerPath`).",
"scope": "window"
},
"cairo1.scarbPath": {
Expand Down
38 changes: 9 additions & 29 deletions src/lsExecutable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import * as vscode from "vscode";
import { Scarb } from "./scarb";
import { findScarbForWorkspaceFolder } from "./cairols";
import { Context } from "./context";
import { isScarbProject } from "./scarbProject";
import { StandaloneLS } from "./standalonels";

export async function getLSExecutables(
Expand Down Expand Up @@ -93,35 +92,16 @@ export async function determineLanguageServerExecutableProvider(
return await standalone();
}

if (await isScarbProject()) {
log.trace("this is a Scarb project");

if (!ctx.config.get("preferScarbLanguageServer", true)) {
log.trace("`preferScarbLanguageServer` is false, using standalone LS");
return await standalone();
}

if (await scarb.hasCairoLS(ctx)) {
log.trace("using Scarb LS");
return scarb;
}

log.trace("Scarb has no LS extension, falling back to standalone");
if (!ctx.config.get("preferScarbLanguageServer", true)) {
log.trace("`preferScarbLanguageServer` is false, using standalone LS");
return await standalone();
} else {
log.trace("this is *not* a Scarb project, looking for standalone LS");
}

try {
return await standalone();
} catch (e) {
log.trace("could not find standalone LS, trying Scarb LS");
if (await scarb.hasCairoLS(ctx)) {
log.trace("using Scarb LS");
return scarb;
}

log.trace("could not find standalone LS and Scarb has no LS extension, will error out");
throw e;
}
if (await scarb.hasCairoLS(ctx)) {
log.trace("using Scarb LS");
return scarb;
}

log.trace("Scarb has no LS extension, falling back to standalone");
return await standalone();
}
25 changes: 0 additions & 25 deletions src/scarbProject.ts

This file was deleted.

0 comments on commit 72e02c1

Please sign in to comment.