@@ -128,7 +128,7 @@ async function getGHCVersion() {
128 sendPermanentNotification(
128 sendPermanentNotification(
129 tool + " not installed!",
129 tool + " not installed!",
130 "Please install " + tool +
130 "Please install " + tool +
131− " and restart Haskell Language Server.",
131+ " and restart Haskell Language Server.",
134 sendPermanentNotification("Couldn't detect GHC version", x);
134 sendPermanentNotification("Couldn't detect GHC version", x);
@@ -141,7 +141,24 @@ async function getGHCVersion() {
141 return promise;
141 return promise;
143async function getHLS() {
143async function getHLS() {
144+ const explicitPath = nova.workspace.config.get("haskell-language-server-path")
146+ sendNotification("HLS path specified in settings", "Using the path to haskell-language-server specified in settings.")
144 const version = await getGHCVersion();
150 const version = await getGHCVersion();
151+ const localHLSPath = await which("haskell-language-server").catch((_) => null)
153+ sendNotification("Found HLS", "Found haskell-language-server in PATH. Checking if it is the right version.")
154+ const v = await getHLSVersion(localHLSPath)
155+ if (v === version) {
156+ sendNotification("Using local HLS", "The haskell-language-server in PATH has the right version. Using it.")
159+ sendNotification("Not using local HLS", "The haskell-language-server in PATH is built fot GHC " + v + " but we need GHC " + version + ". Trying other alternatives.")
145 return await getTool(version);
162 return await getTool(version);
@@ -156,3 +173,37 @@ function getToolName(name) {
156function notifyToolDownloading(name) {
173function notifyToolDownloading(name) {
157 sendNotification("Downloading tool", "Downloading " + getToolName(name));
174 sendNotification("Downloading tool", "Downloading " + getToolName(name));
177+function getHLSVersion(path) {
178+ return call(new Process(path, {
179+ args: ["--version"],
181+ .then((x) => x.match(/\(GHC: (\S+)\)/)[1].trim())
182+ .catch((err) => sendPermanentNotification("HLS version check failed", err))
185+function which(name) {
186+ return call(new Process("/usr/bin/which", {
189+ })).then((p) => p.trim())
192+function call(process) {
193+ const promise = new Promise((resolve, reject) => {
194+ process.onDidExit((exitCode) => {
195+ console.log(exitCode)
196+ if (exitCode == 0) {
197+ readStream(process.stdout).then((x) => {
201+ readStream(process.stderr).then((x) => {