Skip to content

Commit b8acdfa

Browse files
committed
Clarify and discover user configs
1 parent 29b3053 commit b8acdfa

2 files changed

Lines changed: 32 additions & 22 deletions

File tree

commands.ts

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -319,57 +319,67 @@ async function _listInstalledLibraries(context: ExtensionContext) {
319319
}
320320

321321
export async function listConfiguredLibraries(): Promise<ConfiguredLibraryEntry[]> {
322-
const CONFIG_SECTION = 'als-wasm-loader'
322+
const CONFIG_SECTION = 'alsWasmLoader'
323323
const CONFIG_KEY = 'libraryFilePaths'
324324

325-
const resolvedConfigs: ConfiguredLibraryEntry[] = []
325+
const configsFound: ConfiguredLibraryEntry[] = []
326326

327327
const unscopedConfig = workspace.getConfiguration(CONFIG_SECTION)
328-
329-
// TODO: resolve global config
328+
const unscopedConfigSources = unscopedConfig.inspect<string[]>(CONFIG_KEY)
329+
330+
const globalPaths = unscopedConfigSources?.globalValue
331+
if (globalPaths?.length) {
332+
configsFound.push({
333+
source: 'global',
334+
base: '/',
335+
paths: globalPaths,
336+
})
337+
}
330338

331339
const folders = workspace.workspaceFolders
332-
if (!folders?.length) return resolvedConfigs
340+
// we should have reversed the array, but the result (either 0 or 1 element) is the same; see below
341+
if (!folders?.length) return configsFound
333342

334-
const wsPaths = unscopedConfig.inspect<string[]>(CONFIG_KEY)?.workspaceValue
343+
const wsPaths = unscopedConfigSources?.workspaceValue
335344

336345
if (folders.length === 1) {
337346
if (wsPaths?.length) {
338-
resolvedConfigs.push({
347+
configsFound.push({
339348
source: 'workspace',
340349
base: '/workspace',
341350
paths: wsPaths,
342351
})
343352
}
344353
} else if (folders.length > 1) {
354+
if (wsPaths?.length) {
355+
// this path is virtual; it makes sense only if the first component is a workspace folder path
356+
configsFound.push({
357+
source: 'workspace',
358+
base: '/workspaces',
359+
paths: wsPaths,
360+
})
361+
}
362+
345363
for (const wsf of folders) {
346364
const wsfConfig = workspace.getConfiguration(CONFIG_SECTION, wsf.uri)
347365
const wsfPaths = wsfConfig.inspect<string[]>(CONFIG_KEY)?.workspaceFolderValue
348366
if (wsfPaths?.length) {
349-
resolvedConfigs.push({
367+
configsFound.push({
350368
source: 'workspaceFolder',
351369
base: `/workspaces/${wsf.name}`,
352370
paths: wsfPaths,
353371
})
354372
}
355373
}
356-
357-
if (wsPaths?.length) {
358-
// this path is virtual; it makes sense only if the first component is a workspace folder path
359-
resolvedConfigs.push({
360-
source: 'workspace',
361-
base: '/workspaces',
362-
paths: wsPaths,
363-
})
364-
}
365374
}
366375

367376
window.showInformationMessage('Configured libraries:', {
368377
modal: true,
369-
detail: JSON.stringify(resolvedConfigs, null, 2),
378+
detail: JSON.stringify(configsFound, null, 2),
370379
})
371380

372-
return resolvedConfigs
381+
// we want the more specific scope to appear first
382+
return configsFound.reverse()
373383
}
374384

375385
async function _manageLibraries(context: ExtensionContext, ..._args: any[]) {

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,14 @@
6161
}
6262
],
6363
"configuration": {
64-
"title": "Agda WASM",
64+
"title": "Agda/ALS WASM",
6565
"properties": {
66-
"als-wasm-loader.libraryFilePaths": {
66+
"alsWasmLoader.libraryFilePaths": {
6767
"type": "array",
6868
"items": { "type": "string" },
6969
"default": [],
7070
"scope": "resource",
71-
"markdownDescription": "Paths to [library files](https://agda.readthedocs.io/en/latest/tools/package-system.html#library-files) to be loaded by ALS-WASM. User settings are currently ignored. In workspace (when single-root) or workspace-folder (when multi-root) settings, relative paths are resolved against the corresponding workspace folder. Note that the lists from *all* different scopes will be combined per window."
71+
"markdownDescription": "Paths to [library files](https://agda.readthedocs.io/en/latest/tools/package-system.html#library-files) to be loaded by ALS-WASM inside its VFS. Each member will be inserted as a line after resolution in the `libraries` file.\n\nA path *not* beginning with `/` is interpreted as a relative path, resolved according to the scope it is defined. In user settings it is resolved against `/`, while in workspace (when single-rooted) or workspace-folder (when multi-rooted) settings, relative paths are resolved against the corresponding workspace folder.\n\nNote that the lists from all scopes will be combined per window."
7272
}
7373
}
7474
}

0 commit comments

Comments
 (0)