Skip to content

Commit 6d0269f

Browse files
committed
Such fixes
1 parent 0146d78 commit 6d0269f

File tree

5 files changed

+211
-101
lines changed

5 files changed

+211
-101
lines changed

README.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,57 @@ or set `haskell.serverExecutablePath` (overrides all other settings) to a valid
105105

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

108+
### Setting a specific toolchain
109+
110+
When `manageHLS` is set to `GHCup`, you can define a specific toolchain (`hls`, `ghc`, `cabal` and `stack`),
111+
either globally or per project. E.g.:
112+
113+
```json
114+
{
115+
"haskell.toolchain": {
116+
"hls": "1.6.1.1",
117+
"cabal": "recommended",
118+
"stack": null
119+
}
120+
}
121+
```
122+
123+
This means:
124+
125+
1. install the `ghc` version corresponding to the project (default, because it's omitted)
126+
2. install `hls` 1.6.1.1
127+
3. install the recommended `cabal` version from ghcup
128+
4. don't install any `stack` version
129+
130+
Another config could be:
131+
132+
```json
133+
{
134+
"haskell.toolchain": {
135+
"ghc": "9.2.2",
136+
"hls": "latest"
137+
"cabal": "recommended"
138+
}
139+
}
140+
```
141+
142+
Meaning:
143+
144+
1. install `ghc` 9.2.2 regardless of what the project requires
145+
2. always install latest `hls`, even if it doesn't support the given GHC version
146+
3. install recommended `cabal`
147+
4. install latest `stack` (default, because it's omitted)
148+
149+
The defaults (when omitted) are as follows:
150+
151+
1. install the project required `ghc` (corresponding to `with-compiler` setting in `cabal.project` for example)
152+
2. install the latest `hls` version that supports the project required ghc version
153+
3. install latest `cabal`
154+
3. install latest `stack`
155+
156+
When a the value is `null`, the extension will refrain from installing it.
157+
158+
108159
### Supported GHC versions
109160

110161
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!

package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,12 @@
163163
"default": {},
164164
"markdownDescription": "Define environment variables for the language server."
165165
},
166+
"haskell.promptBeforeDownloads": {
167+
"scope": "machine",
168+
"type": "boolean",
169+
"default": "true",
170+
"markdownDescription": "Prompt before performing any downloads."
171+
},
166172
"haskell.manageHLS": {
167173
"scope": "resource",
168174
"type": "string",

src/extension.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,15 @@ async function activateServerForFolder(context: ExtensionContext, uri: Uri, fold
145145
logger.log(` ${key}: ${value}`);
146146
});
147147

148-
let serverExecutable;
148+
let serverExecutable: string;
149149
let addInternalServerPath: string | undefined; // if we download HLS, add that bin dir to PATH
150150
try {
151-
serverExecutable = await findHaskellLanguageServer(context, logger, currentWorkingDir, folder);
152-
addInternalServerPath = path.dirname(serverExecutable);
151+
[serverExecutable, addInternalServerPath] = await findHaskellLanguageServer(
152+
context,
153+
logger,
154+
currentWorkingDir,
155+
folder
156+
);
153157
if (!serverExecutable) {
154158
return;
155159
}

0 commit comments

Comments
 (0)