From 5c8216566e83759c19a2d35f9cb6cda9d0bdc4e1 Mon Sep 17 00:00:00 2001 From: Jerome Lelong Date: Thu, 21 Nov 2024 12:10:39 +0100 Subject: [PATCH] Add new config latex-workshop.latex.extraExts This variable lists all the file extensions that LW will consider as LaTeX files. --- package.json | 9 +++++++++ src/core/file.ts | 2 ++ src/lw.ts | 3 ++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 654bec5ed..18f1350c5 100644 --- a/package.json +++ b/package.json @@ -1100,6 +1100,15 @@ "default": "%DIR%", "markdownDescription": "The directory where the extension tries to find project files (e.g., PDF and SyncTeX files) are located. Both relative and absolute paths are supported. Relative path start from the root file location, so beware if it is located in sub-directory. The path must not contain a trailing slash. The LaTeX toolchain should output files to this path. For a list of supported placeholders, please visit https://github.com/James-Yu/LaTeX-Workshop/wiki/Compile#placeholders. Note that if this config is set to %DIR% (default value) or %DIR_W32%, the extension will try to parse the last LaTeX tools used and look for `-out-directory=` and `-outdir=`, and automatically determine the output directory. This means that you can safely ignore this config if you use `latexmk` and do not manually `mv` the output files in your recipe." }, + "latex-workshop.latex.extraExts": { + "scope": "resource", + "type": "array", + "items": { + "type": "string" + }, + "default": [], + "markdownDescription": "The list of extra file extensions to be considered as LaTeX files. The extension will parse these files for references and to provide intellisense." + }, "latex-workshop.latex.jobname": { "scope": "resource", "type": "string", diff --git a/src/core/file.ts b/src/core/file.ts index 04b9ff892..dd0834efd 100644 --- a/src/core/file.ts +++ b/src/core/file.ts @@ -98,6 +98,7 @@ function handleTmpDirError(error: Error) { function hasTeXExt(extname: string): boolean { return [ ...lw.constant.TEX_EXT, + ...lw.constant.EXTRA_TEX_EXT, ...lw.constant.RSWEAVE_EXT, ...lw.constant.JLWEAVE_EXT, ...lw.constant.PWEAVE_EXT @@ -123,6 +124,7 @@ function hasTeXExt(extname: string): boolean { function hasBinaryExt(extname: string): boolean { return ![ ...lw.constant.TEX_EXT, + ...lw.constant.EXTRA_TEX_EXT, ...lw.constant.TEX_NOCACHE_EXT, ...lw.constant.RSWEAVE_EXT, ...lw.constant.JLWEAVE_EXT, diff --git a/src/lw.ts b/src/lw.ts index 83dde85ea..cde5d0c4a 100644 --- a/src/lw.ts +++ b/src/lw.ts @@ -60,6 +60,7 @@ export const lw = { const constant = { TEX_EXT: ['.tex', '.bib'], + EXTRA_TEX_EXT: vscode.workspace.getConfiguration('latex-workshop').get('latex.extraExts', []) as string[], TEX_NOCACHE_EXT: ['.cls', '.sty', '.bst', '.bbx', '.cbx', '.def', '.cfg'], RSWEAVE_EXT: ['.rnw', '.Rnw', '.rtex', '.Rtex', '.snw', '.Snw'], JLWEAVE_EXT: ['.jnw', '.jtexw'], @@ -69,7 +70,7 @@ const constant = { MAGIC_PROGRAM_ARGS_SUFFIX: '_WITH_ARGS', MAX_PRINT_LINE: '10000', /** - * Prefix that server.ts uses to distiguish requests on pdf files from + * Prefix that server.ts uses to distinguish requests on pdf files from * others. We use '.' because it is not converted by encodeURIComponent and * other functions. * See https://stackoverflow.com/questions/695438/safe-characters-for-friendly-url