Skip to content

Introduce 'haskell.toolchain' setting #562

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

Merged
merged 5 commits into from
Apr 3, 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
51 changes: 51 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,57 @@ or set `haskell.serverExecutablePath` (overrides all other settings) to a valid

If you need to set mirrors for ghcup download info, check the settings `haskell.metadataURL` and `haskell.releasesURL`.

### Setting a specific toolchain

When `manageHLS` is set to `GHCup`, you can define a specific toolchain (`hls`, `ghc`, `cabal` and `stack`),
either globally or per project. E.g.:

```json
{
"haskell.toolchain": {
"hls": "1.6.1.1",
"cabal": "recommended",
"stack": null
}
}
```

This means:

1. install the `ghc` version corresponding to the project (default, because it's omitted)
2. install `hls` 1.6.1.1
3. install the recommended `cabal` version from ghcup
4. don't install any `stack` version

Another config could be:

```json
{
"haskell.toolchain": {
"ghc": "9.2.2",
"hls": "latest"
"cabal": "recommended"
}
}
```

Meaning:

1. install `ghc` 9.2.2 regardless of what the project requires
2. always install latest `hls`, even if it doesn't support the given GHC version
3. install recommended `cabal`
4. install latest `stack` (default, because it's omitted)

The defaults (when omitted) are as follows:

1. install the project required `ghc` (corresponding to `with-compiler` setting in `cabal.project` for example)
2. install the latest `hls` version that supports the project required ghc version
3. install latest `cabal`
3. install latest `stack`

When a the value is `null`, the extension will refrain from installing it.


### Supported GHC versions

These are the versions of GHC that there are binaries of `haskell-language-server-1.6.1` for. Building from source may support more versions!
Expand Down
26 changes: 10 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,12 @@
"default": {},
"markdownDescription": "Define environment variables for the language server."
},
"haskell.promptBeforeDownloads": {
"scope": "machine",
"type": "boolean",
"default": "true",
"markdownDescription": "Prompt before performing any downloads."
},
"haskell.manageHLS": {
"scope": "resource",
"type": "string",
Expand All @@ -177,23 +183,11 @@
"Discovers HLS and other executables in system PATH"
]
},
"haskell.installStack": {
"scope": "resource",
"type": "boolean",
"default": true,
"description": "Whether to also install/manage stack when 'manageHLS' is set to 'GHCup'."
},
"haskell.installCabal": {
"scope": "resource",
"type": "boolean",
"default": true,
"description": "Whether to also install/manage cabal when 'manageHLS' is set to 'GHCup'."
},
"haskell.installGHC": {
"haskell.toolchain": {
"scope": "resource",
"type": "boolean",
"default": true,
"description": "Whether to also install/manage GHC when 'manageHLS' is set to 'GHCup'."
"type": "object",
"default": {},
"description": "When manageHLS is set to GHCup, this can overwrite the automatic toolchain configuration with a more specific one. When a tool is omitted, the extension will manage the version (for 'ghc' we try to figure out the version the project requires). The format is '{\"tool\": \"version\", ...}'. 'version' accepts all identifiers that 'ghcup' accepts."
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a link in the GHCup documentation we could point to?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is rather vscode specific and described in the readme.

},
"haskell.upgradeGHCup": {
"scope": "resource",
Expand Down
10 changes: 7 additions & 3 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,15 @@ async function activateServerForFolder(context: ExtensionContext, uri: Uri, fold
logger.log(` ${key}: ${value}`);
});

let serverExecutable;
let serverExecutable: string;
let addInternalServerPath: string | undefined; // if we download HLS, add that bin dir to PATH
try {
serverExecutable = await findHaskellLanguageServer(context, logger, currentWorkingDir, folder);
addInternalServerPath = path.dirname(serverExecutable);
[serverExecutable, addInternalServerPath] = await findHaskellLanguageServer(
context,
logger,
currentWorkingDir,
folder
);
if (!serverExecutable) {
return;
}
Expand Down
Loading