on master help sign in
5 files changed+464−398
since splitsnapshots
unifiedsplit
Haskell Language Server.novaextension/Scripts/download.js+42−1 Haskell Language Server.novaextension/Scripts/main.js+5−6 Haskell Language Server.novaextension/Scripts/utils.js+92−1 Haskell Language Server.novaextension/Syntaxes/Haskell.xml+125−231 Haskell Language Server.novaextension/extension.json+200−159
Haskell Language Server.novaextension/Scripts/download.js+42−1
@@ -5,6 +5,8 @@ const {
55const {
66 readStream,
77 getStorage,
8+ call,
9+ hasCustomEnv
810} = require("utils");
911
1012exports.getHLS = getHLS;
@@ -43,6 +45,9 @@ async function downloadTool(name) {
4345 const storagePath = getStorageForTool(name);
4446 console.log("Downloading " + storagePath);
4547 const urls = await getHLSAssets();
48+ if (!(name in urls)) {
49+ sendPermanentNotification("There is no pre-built HLS for GHC " + name ,"There is no pre-built version of HLS for GHC " + name + ". You can either build HLS yourself or update your project to one of the pre-built versions: https://github.com/haskell/haskell-language-server/releases")
50+ }
4651 const response = await fetch(urls[name]);
4752 if (!response.ok) {
4853 console.error(response.statusText);
@@ -128,7 +133,7 @@ async function getGHCVersion() {
128133 sendPermanentNotification(
129134 tool + " not installed!",
130135 "Please install " + tool +
131− " and restart Haskell Language Server.",
136+ " and restart Haskell Language Server.",
132137 );
133138 } else {
134139 sendPermanentNotification("Couldn't detect GHC version", x);
@@ -141,7 +146,28 @@ async function getGHCVersion() {
141146 return promise;
142147}
143148async function getHLS() {
149+ const explicitPath = nova.workspace.config.get("haskell-language-server-path")
150+ if (explicitPath) {
151+ sendNotification("HLS path specified in settings", "Using the path to haskell-language-server specified in settings.")
152+ return explicitPath
153+ }
154+
155+ const localHLSPath = await which("haskell-language-server").catch((_) => null)
156+ if (hasCustomEnv() && localHLSPath) {
157+ return localHLSPath
158+ }
159+
144160 const version = await getGHCVersion();
161+ if (localHLSPath) {
162+ sendNotification("Found HLS", "Found haskell-language-server in PATH. Checking if it is the right version.")
163+ const v = await getHLSVersion(localHLSPath)
164+ if (v === version) {
165+ sendNotification("Using local HLS", "The haskell-language-server in PATH has the right version. Using it.")
166+ return localHLSPath
167+ } else {
168+ sendNotification("Not using local HLS", "The haskell-language-server in PATH is built fot GHC " + v + " but we need GHC " + version + ". Trying other alternatives.")
169+ }
170+ }
145171 return await getTool(version);
146172}
147173
@@ -156,3 +182,18 @@ function getToolName(name) {
156182function notifyToolDownloading(name) {
157183 sendNotification("Downloading tool", "Downloading " + getToolName(name));
158184}
185+
186+function getHLSVersion(path) {
187+ return call(path, {
188+ args: ["--version"],
189+ })
190+ .then((x) => x.match(/\(GHC: (\S+)\)/)[1].trim())
191+ .catch((err) => sendPermanentNotification("HLS version check failed", err))
192+}
193+
194+function which(name) {
195+ return call("/usr/bin/which", {
196+ args: [name],
197+ shell: true,
198+ }).then((p) => p.trim())
199+}
Haskell Language Server.novaextension/Scripts/main.js+5−6
@@ -9,8 +9,9 @@ const {
99 getHLSConfig,
1010} = require("configuration");
1111const {
12− getFileName,
12+ getFileName, createEnv, getEnv
1313} = require("utils");
14+
1415exports.activate = function () {
1516 nova.commands.register("stop", (_workspace) => {
1617 stopServer();
@@ -107,10 +108,12 @@ function applyAllLSPEdits(edits, text) {
107108}
108109let lspClient = null;
109110async function startServer() {
111+ await createEnv()
110112 stopServer();
111113 const path = await getServerPath();
114+ const env = await getEnv()
112115 const serverOptions = {
113− path: path,
116+ path, env,
114117 args: ["lsp", "--cwd", nova.workspace.path],
115118 };
116119 const clientOptions = {
@@ -137,7 +140,3 @@ function stopServer() {
137140function getServerPath() {
138141 return getHLS();
139142}
140−
141−// function getLogPath() {
142−// return getStorage() + "/haskell-language-server.log";
143−// }
Haskell Language Server.novaextension/Scripts/utils.js+92−1
@@ -1,3 +1,8 @@
1+const {
2+ sendNotification,
3+ sendPermanentNotification,
4+} = require("notifications");
5+
16function readStream(readableStream) {
27 return new Promise((resolve, _reject) => {
38 const reader = readableStream.getReader();
@@ -48,4 +53,90 @@ function traceRaw(x) {
4853 return x;
4954}
5055
51−module.exports = { readStream, getStorage, getFileName, trace, traceRaw };
56+async function call(path, args) {
57+ const env = await getEnv()
58+ const process = new Process(path, {...args, ...{env}});
59+ const promise = new Promise((resolve, reject) => {
60+ process.onDidExit((exitCode) => {
61+ console.log(exitCode)
62+ if (exitCode == 0) {
63+ readStream(process.stdout).then((x) => {
64+ resolve(x);
65+ });
66+ } else {
67+ readStream(process.stderr).then((x) => {
68+ reject(x)
69+ });
70+ }
71+ });
72+ })
73+ process.start()
74+ return promise
75+}
76+
77+
78+function parseEnvs(x) {
79+ const env = {}
80+ for (line of x.split("\n")) {
81+ const res = line.match(/(.*?)=(.*)/)
82+ if (res) {
83+ env[res[1]] = res[2]
84+ }
85+ }
86+
87+ console.log(JSON.stringify(env))
88+
89+ return env
90+}
91+
92+let envCache = null
93+
94+async function createEnv() {
95+ const generator = nova.workspace.config.get("env-generator")
96+ if (generator) {
97+ const [prog, ...args] = generator.split(/\s+/)
98+ sendNotification("Generating environment", "Executing " + generator + ".")
99+ const process = new Process(prog, {
100+ shell: true,
101+ args,
102+ cwd: nova.workspace.path
103+ });
104+ const promise = new Promise((resolve, reject) => {
105+ process.onDidExit((exitCode) => {
106+ console.log(exitCode)
107+ if (exitCode == 0) {
108+ readStream(process.stdout).then((x) => {
109+ resolve(x);
110+ });
111+ } else {
112+ readStream(process.stderr).then((x) => {
113+ reject(x)
114+ });
115+ }
116+ });
117+ })
118+ process.start()
119+
120+ const envStr = await promise
121+ .catch((err) => sendPermanentNotification("Generating environment failed", err))
122+ envCache = parseEnvs(envStr)
123+ } else {
124+ envCache = {}
125+ }
126+}
127+
128+async function getEnv() {
129+ console.log(JSON.stringify(envCache))
130+ if (!envCache) {
131+ await createEnv()
132+ }
133+ return envCache
134+}
135+
136+
137+function hasCustomEnv() {
138+ return (nova.workspace.config.get("env-generator") !== null)
139+}
140+
141+module.exports = { readStream, getStorage, getFileName, trace, traceRaw, call, createEnv, hasCustomEnv, getEnv };
142+
Haskell Language Server.novaextension/Syntaxes/Haskell.xml+125−231
@@ -1,9 +1,9 @@
11<?xml version="1.0" encoding="UTF-8"?>
22<syntax name="haskell">
33 <meta>
4− <name>Haskell</name>
5− <type>compiled</type>
6− <preferred-file-extension>hs</preferred-file-extension>
4+ <name>Haskell</name>
5+ <type>compiled</type>
6+ <preferred-file-extension>hs</preferred-file-extension>
77 </meta>
88
99 <detectors>
@@ -57,7 +57,6 @@
5757 <include syntax="self" collection="type-family-definition" />
5858 <include syntax="self" collection="pattern-definition" />
5959 <include syntax="self" collection="type-definition" />
60− <!-- <include syntax="self" collection="type-annotation" /> -->
6160 <include syntax="self" collection="GADT-definition" />
6261 <include syntax="self" collection="instance" />
6362 <include syntax="self" collection="typeclass" />
@@ -66,7 +65,6 @@
6665
6766 <template-scopes>
6867 <include syntax="self" collection="Quote" />
69− <include syntax="self" collection="comments" />
7068 </template-scopes>
7169
7270 <collections>
@@ -79,51 +77,27 @@
7977 </collection>
8078
8179 <collection name="expressions">
82− <include syntax="self" collection="do-bind" />
80+ <scope name="haskell.construct.keyword.at">
81+ <expression>@</expression>
82+ </scope>
83+ <scope name="haskell.construct.keyword.case-arrow">
84+ <expression>-&gt;</expression>
85+ </scope>
86+ <scope name="haskell.construct.keyword.bind-arrow">
87+ <expression>&lt;-</expression>
88+ </scope>
89+ <include syntax="self" collection="keywords" />
8390 <include syntax="self" collection="literal" />
8491 <include syntax="self" collection="operators" />
92+ <include syntax="self" collection="record-match" />
8593 <include syntax="self" collection="list" />
94+ <include syntax="self" collection="view-pattern" />
8695 <include syntax="self" collection="lambda-case" />
8796 <include syntax="self" collection="lambda-head" />
88− <include syntax="self" collection="type-applications" />
89− <include syntax="self" collection="outer-case-expression" />
97+ <include syntax="self" collection="case-expression" />
98+ <include syntax="self" collection="qconid" />
9099 <include syntax="self" collection="qvarid" />
91100 <include syntax="self" collection="tuple" />
92−
93−
94− <!-- Needed for do binds -->
95− <!-- <include syntax="self" collection="pattern-match" /> -->
96− </collection>
97−
98− <collection name="pattern-match">
99− <include syntax="self" collection="literal" />
100− <include syntax="self" collection="tuple-match" />
101− <!-- <include syntax="self" collection="at-pattern" /> -->
102− <include syntax="self" collection="varid" />
103− <include syntax="self" collection="qconid" />
104− <include syntax="self" collection="record-match" />
105− <include syntax="self" collection="list-pattern" />
106− <include syntax="self" collection="view-pattern" />
107− </collection>
108−
109− <collection name="type-applications">
110− <scope name="type-applications">
111− <starts-with>
112− <expression>(\s@)\(</expression>
113− <capture number="1" name="haskell.keyword.operator.typeapplication" />
114− </starts-with>
115− <ends-with>
116− <expression>)</expression>
117− </ends-with>
118− <subscopes>
119− <include syntax="self" collection="type" />
120− </subscopes>
121− </scope>
122− <scope name="type-applications-single">
123− <expression>(@)(\w+)</expression>
124− <capture number="1" name="haskell.keyword.operator.typeapplication" />
125− <capture number="2" name="haskell.identifier.type" />
126− </scope>
127101 </collection>
128102
129103 <collection name="Quote">
@@ -162,8 +136,8 @@
162136 <capture number="1" name="haskell.pattern.record.bracket" />
163137 </ends-with>
164138 <subscopes>
165− <include syntax="self" collection="pattern-match" />
166− <include syntax="self" collection="varid" />
139+ <include syntax="self" collection="comments" />
140+ <include syntax="self" collection="expressions" />
167141 <scope name="record-sep">
168142 <expression>=</expression>
169143 </scope>
@@ -185,6 +159,7 @@
185159 <capture number="1" name="haskell.pattern.record.bracket" />
186160 </ends-with>
187161 <subscopes>
162+ <include syntax="self" collection="comments" />
188163 <scope name="haskell.pattern.record.wildcard">
189164 <expression>\.\.</expression>
190165 </scope>
@@ -211,29 +186,12 @@
211186 <capture number="1" name="haskell.list.bracket" />
212187 </ends-with>
213188 <subscopes>
189+ <include syntax="self" collection="comments" />
214190 <include syntax="self" collection="expressions" />
215191 </subscopes>
216192 </scope>
217193 </collection>
218194
219− <collection name="list-pattern">
220− <symbol type="expression" />
221− <scope name="haskell.pattern.list">
222− <starts-with>
223− <expression>(\[)</expression>
224− <capture number="1" name="haskell.pattern.list.bracket" />
225− </starts-with>
226− <ends-with>
227− <expression>(\])</expression>
228− <capture number="1" name="haskell.pattern.list.bracket" />
229− </ends-with>
230− <subscopes>
231− <include syntax="self" collection="pattern-match" />
232− </subscopes>
233− </scope>
234− </collection>
235−
236−
237195 <collection name="view-pattern">
238196 <scope name="haskell.pattern.view">
239197 <symbol type="expression" />
@@ -250,24 +208,7 @@
250208 <scope name="haskell.pattern.view.operator.arrow">
251209 <expression>-&gt;</expression>
252210 </scope>
253− <include syntax="self" collection="pattern-match" />
254− </subscopes>
255− </scope>
256− </collection>
257−
258− <collection name="tuple-match">
259− <symbol type="expression" />
260− <scope name="haskell.pattern.tuple">
261− <starts-with>
262− <expression>(\()</expression>
263− <capture number="1" name="haskell.pattern.tuple.bracket" />
264− </starts-with>
265− <ends-with>
266− <expression>(\))</expression>
267− <capture number="1" name="haskell.pattern.tuple.bracket" />
268− </ends-with>
269− <subscopes>
270− <include syntax="self" collection="pattern-match" />
211+ <include syntax="self" collection="expressions" />
271212 </subscopes>
272213 </scope>
273214 </collection>
@@ -283,53 +224,11 @@
283224 <capture number="1" name="haskell.case.keyword.condition" />
284225 </ends-with>
285226 <subscopes anchored="true">
286− <include syntax="self" collection="pattern-match" />
287− </subscopes>
288− </scope>
289− </collection>
290−
291− <collection name="case-match">
292− <scope name="case-match">
293− <starts-with>
294− <expression>(?=((\h*)\S.*-&gt;($|\h)))</expression>
295− </starts-with>
296− <ends-with>
297− <expression>-&gt;</expression>
298− </ends-with>
299− <subscopes anchored="true">
300− <include syntax="self" collection="pattern-match" />
301− </subscopes>
302− </scope>
303− </collection>
304−
305− <collection name="inner-case-expressions">
306− <scope name="inner-case-expressions">
307− <starts-with>
308− <expression>(?=((\h*)\S.*-&gt;($|\h)))</expression>
309− </starts-with>
310− <ends-with>
311− <template>^(?!\1)(?!\2\h)(?!\s*$)</template>
312− </ends-with>
313− <subscopes>
314− <include syntax="self" collection="case-match" />
315227 <include syntax="self" collection="expressions" />
316228 </subscopes>
317229 </scope>
318230 </collection>
319231
320− <collection name="outer-case-expression">
321− <scope name="outer-case-expression">
322− <starts-with>
323− <expression>(?=case)</expression>
324− </starts-with>
325− <ends-with />
326− <subscopes anchored="true" skip-whitespace="false">
327− <include syntax="self" collection="case-expression" />
328− <include syntax="self" collection="inner-case-expressions" repeat="true" />
329− </subscopes>
330− </scope>
331− </collection>
332−
333232 <collection name="tuple">
334233 <symbol type="expression" />
335234 <scope name="haskell.tuple">
@@ -342,60 +241,73 @@
342241 <capture number="1" name="haskell.tuple.bracket" />
343242 </ends-with>
344243 <subscopes>
244+ <include syntax="self" collection="comments" />
345245 <include syntax="self" collection="expressions" />
346246 </subscopes>
347247 </scope>
348248 </collection>
349249
350250 <collection name="typeclass">
351− <symbol type="interface" />
352− <scope name="haskell.definition.class">
251+ <scope name="haskell.definition.class.head">
252+ <symbol type="class" scope="global" name-selector="haskell.keyword.construct.class.name">
253+ <context behavior="whitespace" foldable="true" />
254+ </symbol>
353255 <starts-with>
354256 <expression>^(\h*)(class)($|\h)</expression>
355257 <capture number="2" name="haskell.keyword.construct.class" />
356258 </starts-with>
357− <ends-with>
358− <template>^(?!\s+\1\S)(?!\s*$)</template>
359− </ends-with>
360− <subscopes>
361− <scope name="haskell.keyword.construct.where">
259+ <ends-with />
260+ <subscopes anchored="true">
261+ <scope name="haskell.keyword.construct.class.name">
262+ <starts-with>
263+ <expression></expression>
264+ </starts-with>
265+ <ends-with>
266+ <expression>(?=(where|^\s*$))</expression>
267+ </ends-with>
268+ <subscopes>
269+ <include syntax="self" collection="comments" />
270+ <include syntax="self" collection="type" />
271+ </subscopes>
272+ </scope>
273+ <scope name="haskell.keyword.construct.where" optional="true">
362274 <expression>where</expression>
363275 </scope>
364− <include syntax="self" collection="type" />
365− <include syntax="self" collection="type-definition" />
366− <!-- <include syntax="self" collection="type-annotation" /> -->
367− <include syntax="self" collection="definition" />
368276 </subscopes>
369277 </scope>
370278 </collection>
371279
372280 <collection name="instance">
373281 <scope name="haskell.instance">
374− <symbol type="category" />
282+ <symbol type="category" name-selector="haskell.keyword.construct.instance.name">
283+ <context behavior="whitespace" foldable="true" />
284+ </symbol>
375285 <starts-with>
376286 <expression>^(\h*)(instance)($|\h)</expression>
377287 <capture number="2" name="haskell.keyword.construct.instance" />
378288 </starts-with>
379− <ends-with>
380− <template>^(?!\s+\1\S)(?!\s*$)</template>
381− </ends-with>
382− <subscopes>
383− <scope name="haskell.keyword.construct.where">
289+ <ends-with />
290+ <subscopes anchored="true">
291+ <scope name="haskell.keyword.construct.instance.name">
292+ <starts-with>
293+ <expression></expression>
294+ </starts-with>
295+ <ends-with>
296+ <expression>(?=(where|^\s*$))</expression>
297+ </ends-with>
298+ <subscopes>
299+ <include syntax="self" collection="type" />
300+ </subscopes>
301+ </scope>
302+ <scope name="haskell.keyword.construct.where" optional="true">
384303 <expression>where</expression>
385304 </scope>
386− <include syntax="self" collection="type" />
387− <include syntax="self" collection="type-definition" />
388− <include syntax="self" collection="type-annotation" />
389− <include syntax="self" collection="definition" />
390305 </subscopes>
391306 </scope>
392307 </collection>
393308
394309 <collection name="type-family-definition">
395310 <scope name="haskell.definition.type-family.type">
396− <symbol type="type">
397− <context behavior="subtree" foldable="false" />
398− </symbol>
399311 <starts-with>
400312 <expression>^(\h*)(type\h+family)</expression>
401313 <capture number="2" name="haskell.keyword.construct.type-family" />
@@ -434,6 +346,7 @@
434346 <template>^(?!\s+\1\S)(?!\s*$)</template>
435347 </ends-with>
436348 <subscopes>
349+ <include syntax="self" collection="comments" />
437350 <include syntax="self" collection="type" optional="true" repeat="true" />
438351 <scope>
439352 <expression>=</expression>
@@ -446,65 +359,26 @@
446359 <collection name="definition">
447360 <scope name="haskell.definition.type.function">
448361 <symbol type="function">
449− <display-name>
450− <component selector="haskell.definition.type.function" />
451− </display-name>
452−
362+ <context behavior="whitespace" foldable="true" />
453363 </symbol>
454364 <starts-with>
455365 <expression>^(?=(\h*)(default\h+)?`?(\w(\w|')*)`?($|\h))</expression>
456366 <capture number="2" name="haskell.keyword.construct.default" />
457− <capture number="3" name="haskell.identifier.function" />
367+ <capture number="3" name="haskell.identifier.function.name" />
458368 </starts-with>
459369 <ends-with>
460370 <template>^(?!\1\3\s)(?!\s+\1\S)(?!\s*$)</template>
461371 </ends-with>
462372 <subscopes>
373+ <include syntax="self" collection="comments" />
463374 <include syntax="self" collection="type-annotation" />
464375 <include syntax="self" collection="implementation" />
465376 </subscopes>
466377 </scope>
467378 </collection>
468379
469− <collection name="do-bind">
470− <scope name="do-bind">
471− <starts-with>
472− <expression>^(?=((\h*)\S.+&lt;-($|\h)))</expression>
473− </starts-with>
474− <ends-with>
475− <template>^(?!\1)(?!\2\h)(?!\s*$)</template>
476− </ends-with>
477− <subscopes>
478− <include syntax="self" collection="do-pattern" />
479− <include syntax="self" collection="expressions" />
480− <!-- <scope name="bind-arrow">
481− <expression>&lt;-</expression>
482− </scope> -->
483− </subscopes>
484− </scope>
485− </collection>
486−
487− <collection name="do-pattern">
488− <scope name="do-pattern">
489− <starts-with>
490− <expression>^(?=((\h*)\S.+&lt;-($|\h)))</expression>
491− </starts-with>
492− <ends-with>
493− <expression>&lt;-</expression>
494− </ends-with>
495− <subscopes>
496− <include syntax="self" collection="pattern-match" />
497− <!-- <scope name="bind-arrow">
498− <expression>&lt;-</expression>
499− </scope>
500− <include syntax="self" collection="expressions" repeat="true" /> -->
501− </subscopes>
502− </scope>
503− </collection>
504−
505380 <collection name="implementation">
506− <scope name="haskell.definition.type.function">
507− <local scope="within-construct" />
381+ <scope name="haskell.definition.type.function.implementation">
508382 <starts-with>
509383 <expression>^(\h*)(default\h+)?`?(\w(\w|')*)`?($|\h)</expression>
510384 <capture number="2" name="haskell.keyword.construct.default" />
@@ -514,14 +388,20 @@
514388 <template>^(?!\1\3\s)(?!\s+\1\S)(?!\s*$)</template>
515389 </ends-with>
516390 <subscopes>
517− <include syntax="self" collection="where-clause" />
518− <include syntax="self" collection="expressions" />
391+ <include syntax="self" collection="comments" />
392+ <include syntax="self" collection="pattern-match" optional="true" repeat="true" />
393+ <scope>
394+ <expression>=</expression>
395+ <capture number="0" name="haskell.construct.function.keyword.eq" />
396+ </scope>
397+ <include syntax="self" collection="expressions" optional="true" repeat="true" />
398+ <include syntax="self" collection="where-clause" optional="true" />
519399 </subscopes>
520400 </scope>
521401 </collection>
522402
523403 <collection name="type-annotation">
524− <scope name="haskell.definition.type.function">
404+ <scope name="haskell.definition.type.function.type-signature">
525405 <starts-with>
526406 <expression>^(\h*)`?(\w(\w|')*)`?\h*::($|\h)</expression>
527407 <capture number="2" name="haskell.identifier.function" />
@@ -530,6 +410,7 @@
530410 <template>^(?!\s+\1\S)(?!\s*$)</template>
531411 </ends-with>
532412 <subscopes>
413+ <include syntax="self" collection="comments" />
533414 <include syntax="self" collection="type" />
534415 </subscopes>
535416 </scope>
@@ -537,15 +418,19 @@
537418
538419 <collection name="type-definition">
539420 <scope name="haskell.definition.type">
421+ <symbol type="type" scope="global">
422+ <context behavior="whitespace" foldable="true" />
423+ </symbol>
540424 <starts-with>
541425 <expression>^(\h*)(type)\h+(\w(\w|')*)</expression>
542426 <capture number="2" name="haskell.keyword.construct.type" />
543− <capture number="3" name="haskell.identifier.type" />
427+ <capture number="3" name="haskell.identifier.type.name" />
544428 </starts-with>
545429 <ends-with>
546430 <template>^(?!\s+\1\S)(?!\s*$)</template>
547431 </ends-with>
548432 <subscopes>
433+ <include syntax="self" collection="comments" />
549434 <include syntax="self" collection="type" />
550435 </subscopes>
551436 </scope>
@@ -553,7 +438,7 @@
553438
554439 <collection name="GADT-definition">
555440 <scope name="haskell.definition.struct.GADT">
556− <symbol type="struct">
441+ <symbol type="struct" scope="global">
557442 <context behavior="subtree" foldable="false" />
558443 </symbol>
559444 <starts-with>
@@ -565,6 +450,7 @@
565450 <template>^(?!\s+\1\S)(?!\s*$)</template>
566451 </ends-with>
567452 <subscopes>
453+ <include syntax="self" collection="comments" />
568454 <scope name="haskell.keyword.construct.where">
569455 <expression>where</expression>
570456 </scope>
@@ -580,21 +466,26 @@
580466 <collection name="gadt-constructor">
581467 <scope name="haskell.identifier.type.struct.data.constructor">
582468 <symbol type="constructor">
583− <context behavior="whitespace" />
469+ <context behavior="subtree" foldable="true" />
584470 </symbol>
585− <expression>(^|=|\|)\h+([A-Z](\w|')*)</expression>
586− <capture number="2" name="haskell.identifier.data.name" />
587− </scope>
588− <scope name="identifier.type.struct.GADT.constructor">
589− <symbol type="constructor"></symbol>
590− <expression>^\h+([A-Z](\w|')*)</expression>
591− <capture number="1" name="haskell.identifier.data.name" />
471+ <starts-with>
472+ <expression>(^|=|\||^)\h+([A-Z](\w|')*)</expression>
473+ <capture number="2" name="haskell.identifier.data.name" />
474+ </starts-with>
475+ <ends-with />
476+ <subscopes anchored="true">
477+ <include syntax="self" collection="record-definition" />
478+ </subscopes>
592479 </scope>
593480 </collection>
594481
595482 <collection name="deriving-clause">
596483 <scope name="haskell.record.construct.deriving.keyword">
597− <expression>deriving\h+(newtype|stock|anyclass)</expression>
484+ <expression>deriving(\h+(newtype|stock|anyclass))?</expression>
485+ </scope>
486+ <scope name="haskell.record.construct.deriving.keyword">
487+ <include syntax="self" collection="comments" />
488+ <expression>via</expression>
598489 </scope>
599490 </collection>
600491
@@ -612,6 +503,7 @@
612503 <capture number="1" name="haskell.record.bracket" />
613504 </ends-with>
614505 <subscopes>
506+ <include syntax="self" collection="comments" />
615507 <include syntax="self" collection="record-definition-field-name" />
616508 <include syntax="self" collection="type" />
617509 </subscopes>
@@ -628,6 +520,13 @@
628520 </collection>
629521
630522 <collection name="type">
523+ <scope name="haskell.keyword.construct.function-arrow">
524+ <expression>-&gt;</expression>
525+ </scope>
526+ <scope name="haskell.keyword.construct.fat-arrow">
527+ <expression>=&gt;</expression>
528+ </scope>
529+ <include syntax="self" collection="strings" />
631530 <scope name="haskell.type.construct.tuple">
632531 <starts-with>
633532 <expression>\(</expression>
@@ -636,6 +535,7 @@
636535 <expression>\)</expression>
637536 </ends-with>
638537 <subscopes>
538+ <include syntax="self" collection="comments" />
639539 <scope name="haskell.construct.type.typle.comma">
640540 <expression>\,</expression>
641541 </scope>
@@ -650,6 +550,7 @@
650550 <expression>\]</expression>
651551 </ends-with>
652552 <subscopes>
553+ <include syntax="self" collection="comments" />
653554 <include syntax="self" collection="type" />
654555 </subscopes>
655556 </scope>
@@ -661,7 +562,7 @@
661562 </scope>
662563 <include syntax="self" collection="type-list" />
663564 <scope>
664− <expression>(([A-Z](\w|')*\.)*)'*([A-Z](\w|')*)</expression>
565+ <expression>(([A-Z](\w|')*\.)*)'*\!?([A-Z](\w|')*)</expression>
665566 <capture number="1" name="haskell.identifier.package.module" />
666567 <capture number="4" name="haskell.identifier.type" />
667568 </scope>
@@ -669,13 +570,7 @@
669570 <expression>forall</expression>
670571 </scope>
671572 <scope name="haskell.identifier.type.variable">
672− <expression>(?!=)((?!(\(|\)|\,))\S)((?!(\(|\)|\,))\S)*</expression>
673− </scope>
674− <scope name="haskell.keyword.construct.function-arrow">
675− <expression>-&gt;</expression>
676− </scope>
677− <scope name="haskell.keyword.construct.fat-arrow">
678− <expression>=&gt;</expression>
573+ <expression>(?!where)(?!=)((?!(\(|\)|\,|\!))\S)((?!(\(|\)|\,))\w)*</expression>
679574 </scope>
680575 </collection>
681576
@@ -690,6 +585,7 @@
690585 <template>^(?!\s+\1\S)(?!\s*$)</template>
691586 </ends-with>
692587 <subscopes>
588+ <include syntax="self" collection="comments" />
693589 <scope name="haskell.keyword.construct.where">
694590 <expression>where</expression>
695591 </scope>
@@ -709,6 +605,7 @@
709605 <capture number="1" name="haskell.type-list.bracket" />
710606 </ends-with>
711607 <subscopes>
608+ <include syntax="self" collection="comments" />
712609 <include syntax="self" collection="type" />
713610 </subscopes>
714611 </scope>
@@ -725,6 +622,7 @@
725622 <capture number="1" name="haskell.keyword.construct.lambda" />
726623 </ends-with>
727624 <subscopes>
625+ <include syntax="self" collection="comments" />
728626 <include syntax="self" collection="pattern-match" />
729627 </subscopes>
730628 </scope>
@@ -738,7 +636,6 @@
738636
739637 <collection name="where-clause">
740638 <scope name="haskell.construct.where">
741− <local scope="within-parent" />
742639 <starts-with>
743640 <expression>^(\h*)(where)</expression>
744641 <capture number="2" name="haskell.construct.keyword.where" />
@@ -747,6 +644,7 @@
747644 <template>^(?!\1\s*\S)(?!s*$)</template>
748645 </ends-with>
749646 <subscopes>
647+ <include syntax="self" collection="comments" />
750648 <include syntax="self" collection="definition" />
751649 </subscopes>
752650 </scope>
@@ -786,12 +684,12 @@
786684
787685
788686 <collection name="strings">
789− <scope name="haskell.string.double-quoted">
687+ <scope name="haskell.string.double-quoted" spell-check="true">
790688 <starts-with>
791− <expression>"</expression>
689+ <expression>&quot;</expression>
792690 </starts-with>
793691 <ends-with>
794− <expression>"</expression>
692+ <expression>&quot;</expression>
795693 </ends-with>
796694 <subscopes>
797695 <scope name="haskell.string.escape-sequences">
@@ -828,6 +726,7 @@
828726 </ends-with>
829727 <subscopes>
830728 <scope name="identifier.haskell.type">
729+ <symbol type="expression" />
831730 <symbol type="expression" />
832731 <expression>([A-Z](\w|')*)\h*(\(\h*\.\.\h*\))?</expression>
833732 <capture number="1" name="identifier.type" />
@@ -852,6 +751,7 @@
852751 </ends-with>
853752 <subscopes>
854753 <scope name="haskell.construct.qualified">
754+ <symbol type="expression" />
855755 <expression>qualified</expression>
856756 <capture number="0" name="haskell.construct.keyword.qualified" />
857757 </scope>
@@ -869,6 +769,7 @@
869769 </ends-with>
870770 <subscopes anchored="true">
871771 <include syntax="self" collection="import-list" />
772+ <symbol type="expression" />
872773 </subscopes>
873774 </scope>
874775
@@ -902,6 +803,7 @@
902803 </ends-with>
903804 <subscopes>
904805 <scope name="haskell.identifier.struct">
806+ <symbol type="expression" />
905807 <symbol type="reference" scope="local" />
906808 <expression>([A-Z](\w|')*)\h*(\(\h*\.\.\h*\))?</expression>
907809 <capture number="1" name="haskell.import-list.identifier.type.name" />
@@ -915,13 +817,6 @@
915817 </scope>
916818 </collection>
917819
918− <!-- <collection name="special">
919− <scope>
920− <expression>(;|,)</expression>
921− </scope>
922− </collection> -->
923−
924−
925820 <collection name="reservedop">
926821 <scope name="keyword.operator">
927822 <expression>(\.\.|:|::|=|\\|\||&lt;-|-&gt;|@|~|=>)</expression>
@@ -929,10 +824,11 @@
929824 </collection>
930825
931826 <collection name="keywords">
932− <scope name="haskell.keyword.modifier">
827+ <scope name="haskell.keyword.self">
933828 <symbol type="keyword" />
934829 <strings>
935830 <string>do</string>
831+ <string>mdo</string>
936832 <string>in</string>
937833 <string>infix</string>
938834 <string>infixl</string>
@@ -970,20 +866,18 @@
970866 <strings>
971867 <string>undefined</string>
972868 <string>_</string>
869+ <string>@</string>
973870 </strings>
974871 </scope>
975872 </collection>
976873
977874 <collection name="comments">
978875 <scope name="haskell.comment.single" spell-check="true">
979− <starts-with>
980− <expression>--</expression>
981− </starts-with>
982− <ends-with>
983− <expression>$</expression>
984− </ends-with>
876+ <symbol type="comment" />
877+ <expression> --.*$</expression>
985878 </scope>
986879 <scope name="haskell.comment.block" spell-check="true">
880+ <symbol type="comment" />
987881 <starts-with>
988882 <expression>{-</expression>
989883 </starts-with>
@@ -995,4 +889,4 @@
995889
996890
997891 </collections>
998−</syntax>
892+</syntax>
Haskell Language Server.novaextension/extension.json+200−159
@@ -6,292 +6,333 @@
66 "version": "1.0",
77 "categories": ["languages", "formatters"],
88 "main": "main.js",
9− "entitlements": {
9+ "entitlements":
10+ {
1011 "process": true,
1112 "filesystem": "readwrite",
1213 "requests": true
1314 },
14− "configWorkspace": [{
15+ "configWorkspace": [
16+ {
1517 "key": "haskell-language-server-path",
1618 "title": "Haskell Language Server path",
1719 "description": "If you want to use a custom HLS build for this project, then specify the path to it here.",
1820 "type": "path",
1921 "placeholder": "/usr/local/bin/example"
20− }, {
22+ },
23+ {
24+ "key": "env-generator",
25+ "title": "Environment generator",
26+ "description": "You can specify a shell command which will be used to generate the environment, in which the extension will be executes. This is useful if you want to utilize `nix-shell`, `direnv` or any similar command.\n\nExpects the command to have the same stdout as the `env` command.",
27+ "type": "enum",
28+ "allowsCustom": true,
29+ "values": ["nix-shell --run env", "direnv exec env"]
30+ },
31+ {
2132 "type": "section",
2233 "title": "Haskell Language Server settings",
23− "children": [{
24− "key": "haskell.formattingProvider",
25− "title": "Code formatter",
26− "type": "enum",
27− "values": [
28− "brittany",
29− "floskell",
30− "fourmolu",
31− "ormolu",
32− "stylish-haskell",
33− "none"
34− ],
35− "default": "ormolu",
36− "description": "The formatter to use when formatting a document or range. Ensure the plugin is enabled."
37− }, {
38− "key": "haskell.checkProject",
39− "title": "Check whole project",
40− "type": "boolean",
41− "default": false,
42− "description": "Whether to typecheck the entire project on load. It could drive to bad perfomance in large projects."
43− }, {
44− "key": "haskell.maxCompletions",
45− "type": "number",
46− "title": "Maximum number of completions",
47− "description": "Maximum number of completions sent to the editor.",
48− "default": 40
49− }, {
50− "type": "section",
51− "title": "Plugin settings",
52− "children": [{
34+ "description":"Some of the features are not supported in Nova. Some of them are explicitly marked as not supported, but it is not exhaustive.",
35+ "children": [
36+ {
37+ "key": "haskell.formattingProvider",
38+ "title": "Code formatter",
39+ "type": "enum",
40+ "values": [
41+ "brittany",
42+ "floskell",
43+ "fourmolu",
44+ "ormolu",
45+ "stylish-haskell",
46+ "none"
47+ ],
48+ "default": "ormolu",
49+ "description": "The formatter to use when formatting a document or range. Ensure the plugin is enabled."
50+ },
51+ {
52+ "key": "haskell.checkProject",
53+ "title": "Check whole project",
54+ "type": "boolean",
55+ "default": false,
56+ "description": "Whether to typecheck the entire project on load. It could lead to bad perfomance in large projects."
57+ },
58+ {
59+ "title": "Completions",
5360 "type": "section",
54− "title": "Import lens",
55− "description": "Not currently implemented in Nova",
56− "children": [{
57− "key": "haskell.plugin.importLens.codeActionsOn",
58− "title": "Enable code actions",
59− "type": "boolean",
61+ "children": [
62+ {
63+ "key": "haskell.plugin.ghcide-completions.config.autoExtendOn",
64+ "title": "Extend with out-of-scope identifiers",
65+ "description": "Extends the import list automatically when completing a out-of-scope identifier",
6066 "default": true,
61− "description": "Enables explicit imports code actions"
62− }, {
63− "key": "haskell.plugin.importLens.codeLensOn",
64− "title": "Enable code lens",
65− "type": "boolean",
67+ "type": "boolean"
68+ },
69+ {
70+ "key": "haskell.plugin.ghcide-completions.config.snippetsOn",
71+ "title": "Insert snippets",
72+ "description": "Inserts snippets when using code completions",
6673 "default": true,
67− "description": "Enables explicit imports code lenses"
74+ "type": "boolean"
75+ },
76+ {
77+ "key": "haskell.maxCompletions",
78+ "type": "number",
79+ "title": "Maximum number of completions",
80+ "description": "Maximum number of completions sent to the editor.",
81+ "default": 40
6882 }]
69− }, {
83+ },
84+ {
7085 "title": "HLint",
7186 "type": "section",
72− "children": [{
87+ "children": [
88+ {
7389 "key": "haskell.plugin.hlint.codeActionsOn",
7490 "title": "Enable code actions",
7591 "type": "boolean",
7692 "default": true,
7793 "description": "Enables hlint code actions (apply hints)"
78− }, {
94+ },
95+ {
7996 "key": "haskell.plugin.hlint.diagnosticsOn",
8097 "title": "Enable diagnostics",
8198 "type": "boolean",
8299 "default": true,
83100 "description": "Enables hlint diagnostics"
84− }, {
85− "title": "Configuration",
86− "type": "section",
87− "children": [{
88− "key": "haskell.plugin.hlint.config.flags",
89− "title": "Flags",
90− "description": "Flags used by hlint",
91− "default": [],
92− "type": "stringArray"
93− }]
101+ },
102+ {
103+ "key": "haskell.plugin.hlint.config.flags",
104+ "title": "Flags",
105+ "description": "Flags used by hlint",
106+ "default": [],
107+ "type": "stringArray"
108+ }]
109+ },
110+ {
111+ "type": "section",
112+ "title": "Import lens",
113+ "description": "Not currently implemented in Nova",
114+ "children": [
115+ {
116+ "key": "haskell.plugin.importLens.codeActionsOn",
117+ "title": "Enable code actions",
118+ "type": "boolean",
119+ "default": true,
120+ "description": "Enables explicit imports code actions"
121+ },
122+ {
123+ "key": "haskell.plugin.importLens.codeLensOn",
124+ "title": "Enable code lens",
125+ "type": "boolean",
126+ "default": true,
127+ "description": "Enables explicit imports code lenses"
94128 }]
95− }, {
129+ },
130+
131+ {
96132 "title": "Eval",
97133 "type": "section",
98− "children": [{
134+ "children": [
135+ {
99136 "key": "haskell.plugin.eval.globalOn",
100137 "title": "Enable",
101138 "type": "boolean",
102139 "default": true,
103140 "description": "Enables eval plugin"
104141 }]
105− }, {
142+ },
143+ {
106144 "title": "Module name",
107145 "type": "section",
108− "children": [{
146+ "children": [
147+ {
109148 "key": "haskell.plugin.moduleName.globalOn",
110149 "title": "Enable",
111150 "type": "boolean",
112151 "default": true,
113152 "description": "Enables module name plugin"
114153 }]
115− }, {
154+ },
155+ {
116156 "title": "Splice",
117157 "type": "section",
118− "children": [{
158+ "children": [
159+ {
119160 "key": "haskell.plugin.splice.globalOn",
120161 "title": "Enable",
121162 "type": "boolean",
122163 "default": true,
123164 "description": "Enables splice plugin (expand template haskell definitions)"
124165 }]
125− }, {
166+ },
167+ {
126168 "title": "Haddock comments",
127169 "type": "section",
128− "children": [{
170+ "children": [
171+ {
129172 "key": "haskell.plugin.haddockComments.globalOn",
130173 "title": "Enable",
131174 "type": "boolean",
132175 "default": true,
133176 "description": "Enables haddock comments plugin"
134177 }]
135− }, {
178+ },
179+ {
136180 "title": "Class",
137181 "type": "section",
138− "children": [{
182+ "children": [
183+ {
139184 "key": "haskell.plugin.class.globalOn",
140185 "title": "Enable",
141186 "type": "boolean",
142187 "default": true,
143188 "description": "Enables type class plugin"
144189 }]
145− }, {
190+ },
191+ {
146192 "title": "Retrie",
147193 "type": "section",
148− "children": [{
194+ "children": [
195+ {
149196 "key": "haskell.plugin.retrie.globalOn",
150197 "title": "Enable",
151198 "type": "boolean",
152199 "default": true,
153200 "description": "Enables retrie plugin"
154201 }]
155− }, {
202+ },
203+ {
156204 "title": "Wingman",
157205 "type": "section",
158− "children": [{
206+ "children": [
207+ {
159208 "key": "haskell.plugin.tactics.globalOn",
160209 "title": "Enable",
161210 "type": "boolean",
162211 "default": true,
163212 "description": "Enables Wingman (tactics) plugin"
164− }, {
165− "title": "Configuration",
166− "type": "section",
167− "children": [{
168− "key": "haskell.plugin.tactics.config.auto_gas",
169− "title": "Gas",
170− "description": "The depth of the search tree when performing \"Attempt to fill hole\". Bigger values will be able to derive more solutions, but will take exponentially more time.",
171− "default": 4,
172− "type": "number"
173− }, {
174− "key": "haskell.plugin.tactics.config.hole_severity",
175− "title": "Hole severity",
176− "description": "The severity to use when showing hole diagnostics.",
177− "values": [
178− 1,
179− 2,
180− 3,
181− 4,
182− null
183− ],
184− "default": null,
185− "type": "enum"
186− }, {
187− "key": "haskell.plugin.tactics.config.max_use_ctor_actions",
188− "title": "Max number of constructors",
189− "type": "number",
190− "default": 5,
191− "description": "Maximum number of `Use constructor <x>` code actions that can appear"
192− }, {
193− "key": "haskell.plugin.tactics.config.timeout_duration",
194− "title": "Timeout",
195− "description": "The timeout for Wingman actions, in seconds",
196− "default": 2,
197− "type": "number"
198− }, {
199− "key": "haskell.plugin.tactics.config.proofstate_styling",
200− "title": "Proof states",
201− "description": "Should Wingman emit styling markup when showing metaprogram proof states?",
202− "default": true,
203− "type": "boolean"
204− }]
213+ },
214+ {
215+ "key": "haskell.plugin.tactics.config.auto_gas",
216+ "title": "Gas",
217+ "description": "The depth of the search tree when performing \"Attempt to fill hole\". Bigger values will be able to derive more solutions, but will take exponentially more time.",
218+ "default": 4,
219+ "type": "number"
220+ },
221+ {
222+ "key": "haskell.plugin.tactics.config.hole_severity",
223+ "title": "Hole severity",
224+ "description": "The severity to use when showing hole diagnostics.",
225+ "values": [
226+ 1,
227+ 2,
228+ 3,
229+ 4,
230+ null
231+ ],
232+ "default": null,
233+ "type": "enum"
234+ },
235+ {
236+ "key": "haskell.plugin.tactics.config.max_use_ctor_actions",
237+ "title": "Max number of constructors",
238+ "type": "number",
239+ "default": 5,
240+ "description": "Maximum number of `Use constructor <x>` code actions that can appear"
241+ },
242+ {
243+ "key": "haskell.plugin.tactics.config.timeout_duration",
244+ "title": "Timeout",
245+ "description": "The timeout for Wingman actions, in seconds",
246+ "default": 2,
247+ "type": "number"
248+ },
249+ {
250+ "key": "haskell.plugin.tactics.config.proofstate_styling",
251+ "title": "Proof states",
252+ "description": "Should Wingman emit styling markup when showing metaprogram proof states?",
253+ "default": true,
254+ "type": "boolean"
205255 }]
206− }, {
256+ },
257+ {
207258 "title": "Pragmas",
208259 "type": "section",
209− "children": [{
260+ "children": [
261+ {
210262 "key": "haskell.plugin.pragmas.codeActionsOn",
211263 "title": "Enable code actions",
212264 "type": "boolean",
213265 "default": true,
214266 "description": "Enables pragmas code actions"
215− }, {
267+ },
268+ {
216269 "key": "haskell.plugin.pragmas.completionOn",
217270 "title": "Enable completions",
218271 "type": "boolean",
219272 "default": true,
220273 "description": "Enables pragmas completions"
221274 }]
222− }, {
223− "title": "Completions",
224− "type": "section",
225− "children": [{
226− "title": "Configuration",
227− "type": "section",
228− "children": [{
229− "key": "haskell.plugin.ghcide-completions.config.autoExtendOn",
230− "title": "Extend with out-of-scope identifiers",
231− "description": "Extends the import list automatically when completing a out-of-scope identifier",
232− "default": true,
233− "type": "boolean"
234− }, {
235− "key": "haskell.plugin.ghcide-completions.config.snippetsOn",
236− "title": "Insert snippets",
237− "description": "Inserts snippets when using code completions",
238− "default": true,
239− "type": "boolean"
240− }]
241− }]
242− }, {
275+ },
276+ {
277+ "title": "Type lenses",
243278 "description": "Not currently implemented in Nova",
244279 "type": "section",
245− "children": [{
280+ "children": [
281+ {
246282 "key": "haskell.plugin.ghcide-type-lenses.globalOn",
247283 "title": "Enable",
248284 "type": "boolean",
249285 "default": true,
250286 "description": "Enables type lenses plugin"
251− }, {
252− "title": "Configuration",
253− "type": "section",
254− "children": [{
255− "key": "haskell.plugin.ghcide-type-lenses.config.mode",
256− "title": "Mode",
257− "type": "enum",
258− "default": true,
259− "description": "Control how type lenses are shown",
260− "values": ["always", "exported", "diagnostics"]
261− }]
287+ },
288+ {
289+ "key": "haskell.plugin.ghcide-type-lenses.config.mode",
290+ "title": "Mode",
291+ "type": "enum",
292+ "default": true,
293+ "description": "Control how type lenses are shown",
294+ "values": ["always", "exported", "diagnostics"]
262295 }]
263− }, {
296+ },
297+ {
264298 "title": "Refine imports",
265299 "type": "section",
266− "children": [{
300+ "children": [
301+ {
267302 "key": "haskell.plugin.refineImports.globalOn",
268303 "title": "Enable",
269304 "type": "boolean",
270305 "default": true,
271306 "description": "Enables refine imports plugin"
272307 }]
273− }]
274− }]
308+ }
309+ ]
275310 }],
276311 "activationEvents": ["onLanguage:haskell", "onLanguage:hs"],
277− "commands": {
278− "editor": [{
312+ "commands":
313+ {
314+ "editor": [
315+ {
279316 "title": "Format file with Haskell Language Server",
280317 "command": "format",
281318 "when": "editorSyntax == 'haskell' && editorHasFocus",
282− "filters": {
319+ "filters":
320+ {
283321 "syntaxes": ["haskell"]
284322 }
285323 }],
286− "extensions": [{
324+ "extensions": [
325+ {
287326 "title": "Stop",
288327 "paletteTitle": "Stop Haskell Language Server",
289328 "command": "stop"
290− }, {
329+ },
330+ {
291331 "title": "Restart",
292332 "paletteTitle": "Restart Haskell Language Server",
293333 "command": "restart"
294− }, {
334+ },
335+ {
295336 "title": "Clear cached versions",
296337 "paletteTitle": "Clear cached versions of Haskell Language Server",
297338 "command": "clear-cache"