diff --git a/package.json b/package.json index bde6df2..5e46f5e 100644 --- a/package.json +++ b/package.json @@ -154,22 +154,32 @@ "default": true, "description": "When snippet is enabled, hide the snippets' corresponding commands from completion items." }, - "texinfo.preview.customCSS": { - "type": "string", - "default": "", - "description": "URI of custom CSS for preview." - }, "texinfo.enableCodeLens": { "type": "boolean", "default": true, "description": "Enable code lens on node identifiers which jumps to the corresponding nodes in preview." }, + "texinfo.makeinfo": { + "type": "string", + "default": "makeinfo", + "description": "Path to the makeinfo (or texi2any) command." + }, + "texinfo.preview.customCSS": { + "type": "string", + "default": "", + "description": "URI of custom CSS for preview." + }, "texinfo.preview.errorLimit": { "type": "integer", "default": 100, "minimum": 0, "description": "Max number of errors before quit when trying to display preview." }, + "texinfo.preview.includePaths": { + "type": "array", + "default": [], + "description": "Extra paths to search for @include files." + }, "texinfo.preview.maxSize": { "type": "integer", "default": 2, @@ -177,11 +187,6 @@ "maximum": 16, "description": "Max allowed size (in MiB) for the preview document." }, - "texinfo.makeinfo": { - "type": "string", - "default": "makeinfo", - "description": "Path to the `makeinfo` (or `texi2any`) command." - }, "texinfo.preview.noHeaders": { "type": "boolean", "default": false, @@ -197,10 +202,10 @@ "default": false, "description": "Suppress warnings." }, - "texinfo.vars": { + "texinfo.preview.variables": { "type": "array", "default": [], - "description": "Define variables." + "description": "Define variables (as with @set)." } } }, diff --git a/src/options.ts b/src/options.ts index cf46d68..36e83ab 100644 --- a/src/options.ts +++ b/src/options.ts @@ -52,6 +52,10 @@ export default class Options { return this.getNumber('preview.errorLimit'); } + get includePaths() { + return this.getArray('preview.includePaths'); + } + get maxSize() { return this.getNumber('preview.maxSize') * 1024 * 1024; } @@ -68,14 +72,14 @@ export default class Options { return this.getBoolean('preview.noWarnings'); } - get vars() { - return this.getArray('vars'); + get variables() { + return this.getArray('preview.variables'); } private readonly configuration = vscode.workspace.getConfiguration('texinfo'); - private getArray(section: string) { - return this.configuration.get(section, []); + private getArray(section: string): readonly string[] { + return this.configuration.get(section, []); } private getBoolean(section: string) { diff --git a/src/utils/converter.ts b/src/utils/converter.ts index cba6d19..1930fdc 100644 --- a/src/utils/converter.ts +++ b/src/utils/converter.ts @@ -19,7 +19,7 @@ * vscode-texinfo. If not, see . */ - import * as path from 'path'; +import * as path from 'path'; import * as vscode from 'vscode'; import Logger from '../logger'; import Options from '../options'; @@ -41,8 +41,9 @@ export default class Converter { if (insertScript !== undefined) { options.push('--set-customization-variable', `EXTRA_HEAD `); } + this.addIncludePaths(this.options.includePaths, options); + this.defineVariables(this.options.variables, options); this.includeCustomCSS(this.options.customCSS, options); - this.addVars(this.options.vars, options); return await exec(this.options.makeinfo, options.concat(this.path), this.options.maxSize); } @@ -53,8 +54,13 @@ export default class Converter { private readonly logger: Logger, ) {} - private addVars(vars: readonly string[], options: string[]) { - vars.forEach(varName => options.push('-D', varName)); + private addIncludePaths(paths: readonly string[], options: string[]) { + const separator = process.platform === 'win32' ? ';' : ':'; + options.push('-I', paths.join(separator)); + } + + private defineVariables(variables: readonly string[], options: string[]) { + variables.forEach(varName => options.push('-D', varName)); } private includeCustomCSS(cssFileURI: string, options: string[]) {