mirror of
https://github.com/James-Yu/LaTeX-Workshop.git
synced 2024-10-04 15:17:59 +03:00
Make configurations take effect without reload
This commit is contained in:
parent
146e53330d
commit
b77ad5d21e
@ -79,7 +79,7 @@
|
||||
"latex-workshop.compiler": {
|
||||
"type": "string",
|
||||
"default": "pdflatex",
|
||||
"description": "LaTeX compiler to use. Default: pdflatex."
|
||||
"description": "LaTeX compiler to use. Reload to take effect. Default: pdflatex."
|
||||
},
|
||||
"latex-workshop.compile_argument": {
|
||||
"type": "string",
|
||||
|
@ -15,7 +15,7 @@ requirejs.config({
|
||||
var compiling = false,
|
||||
to_compile = false;
|
||||
|
||||
export async function compile(non_tex_alert=false) {
|
||||
export async function compile(on_save=true) {
|
||||
vscode.workspace.saveAll();
|
||||
find_main_document();
|
||||
getPreviewPosition();
|
||||
@ -39,14 +39,15 @@ export async function compile(non_tex_alert=false) {
|
||||
latex_workshop.workshop_output.clear();
|
||||
|
||||
// Sequentially execute all commands
|
||||
let cmds = latex_workshop.configuration.compile_workflow;
|
||||
var configuration = vscode.workspace.getConfiguration('latex-workshop');
|
||||
let cmds = configuration.get('compile_workflow') as Array<string>;
|
||||
let error_occurred = false;
|
||||
var log_content;
|
||||
for (let cmd_idx = 0; cmd_idx < cmds.length; ++cmd_idx){
|
||||
// Parse placeholder
|
||||
let cmd = cmds[cmd_idx];
|
||||
cmd = replace_all(cmd, '%compiler%', latex_workshop.configuration.compiler);
|
||||
cmd = replace_all(cmd, '%arguments%', latex_workshop.configuration.compile_argument);
|
||||
cmd = replace_all(cmd, '%compiler%', configuration.get('compiler'));
|
||||
cmd = replace_all(cmd, '%arguments%', configuration.get('compile_argument'));
|
||||
cmd = replace_all(cmd, '%document%', '"' + path.basename(latex_data.main_document, '.tex') + '"');
|
||||
vscode.window.setStatusBarMessage(`LaTeX compilation step ${cmd_idx + 1}: ${cmd}`, 3000);
|
||||
|
||||
@ -80,12 +81,13 @@ export async function compile(non_tex_alert=false) {
|
||||
'warning': 'W',
|
||||
'error': 'E'
|
||||
}
|
||||
var log_level = configuration.get('log_level');
|
||||
if (entries.all.length > 0) {
|
||||
latex_workshop.workshop_output.show();
|
||||
latex_workshop.workshop_output.append('\n------------\nLaTeX Log Parser Result\n');
|
||||
for (var entry of entries.all) {
|
||||
if ((entry.level == 'typesetting' && latex_workshop.configuration.log_level == 'all') ||
|
||||
(entry.level == 'warning' && latex_workshop.configuration.log_level != 'error') ||
|
||||
if ((entry.level == 'typesetting' && log_level == 'all') ||
|
||||
(entry.level == 'warning' && log_level != 'error') ||
|
||||
(entry.level == 'error'))
|
||||
latex_workshop.workshop_output.append(`[${entry_tag[entry.level]}][${entry.file}:${entry.line}] ${entry.message}\n`)
|
||||
}
|
||||
|
@ -9,8 +9,7 @@ var hasbin = require('hasbin');
|
||||
var fs = require('fs');
|
||||
var loader = require("amd-loader");
|
||||
|
||||
export var configuration,
|
||||
latex_output,
|
||||
export var latex_output,
|
||||
workshop_output,
|
||||
preview_provider,
|
||||
has_compiler,
|
||||
@ -20,16 +19,21 @@ export var configuration,
|
||||
export async function activate(context: vscode.ExtensionContext) {
|
||||
find_path = context.asAbsolutePath;
|
||||
console.log('LaTeX Workshop activated.');
|
||||
configuration = vscode.workspace.getConfiguration('latex-workshop');
|
||||
var configuration = vscode.workspace.getConfiguration('latex-workshop');
|
||||
latex_output = vscode.window.createOutputChannel('LaTeX Raw Output');
|
||||
workshop_output = vscode.window.createOutputChannel('LaTeX Workshop Output');
|
||||
|
||||
has_compiler = hasbin.sync(configuration.compiler);
|
||||
has_compiler = hasbin.sync(configuration.get('compiler'));
|
||||
context.subscriptions.push(
|
||||
vscode.commands.registerCommand('latex-workshop.compile', has_compiler ? () => {compile(true)} : deavtivated_feature)
|
||||
vscode.commands.registerCommand('latex-workshop.compile', has_compiler ? () => {
|
||||
if (configuration.get('compile_on_save'))
|
||||
vscode.workspace.saveAll();
|
||||
else
|
||||
compile(false)
|
||||
} : deactivated_feature)
|
||||
);
|
||||
if (!has_compiler) {
|
||||
vscode.window.showWarningMessage(`LaTeX compiler ${configuration.compiler} is not found.`);
|
||||
vscode.window.showWarningMessage(`LaTeX compiler ${configuration.get('compiler')} is not found.`);
|
||||
}
|
||||
|
||||
context.subscriptions.push(
|
||||
@ -40,14 +44,17 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||
|
||||
has_synctex = hasbin.sync('synctex');
|
||||
context.subscriptions.push(
|
||||
vscode.commands.registerCommand('latex-workshop.synctex', has_synctex ? inPreview : deavtivated_feature)
|
||||
vscode.commands.registerCommand('latex-workshop.synctex', has_synctex ? inPreview : deactivated_feature)
|
||||
);
|
||||
if (!has_synctex) {
|
||||
vscode.window.showWarningMessage(`SyncTeX is not found.`);
|
||||
}
|
||||
|
||||
if (has_compiler && configuration.compile_on_save)
|
||||
context.subscriptions.push(vscode.workspace.onDidSaveTextDocument((e: vscode.TextDocument) => compile()));
|
||||
if (has_compiler)
|
||||
context.subscriptions.push(vscode.workspace.onDidSaveTextDocument((e: vscode.TextDocument) => {
|
||||
if (configuration.get('compile_on_save'))
|
||||
compile()
|
||||
}));
|
||||
|
||||
preview_provider = new previewProvider(context);
|
||||
context.subscriptions.push(preview_provider);
|
||||
@ -69,6 +76,6 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||
export function deactivate() {
|
||||
}
|
||||
|
||||
function deavtivated_feature() {
|
||||
function deactivated_feature() {
|
||||
|
||||
}
|
@ -72,8 +72,9 @@ export function find_label_keys() {
|
||||
|
||||
export function find_main_document() {
|
||||
if (latex_data.main_document != undefined) return;
|
||||
if (latex_workshop.configuration.main_document != null) {
|
||||
var file = path.join(vscode.workspace.rootPath, latex_workshop.configuration.main_document);
|
||||
var configuration = vscode.workspace.getConfiguration('latex-workshop');
|
||||
if (configuration.get('main_document') != null) {
|
||||
var file = path.join(vscode.workspace.rootPath, configuration.get('main_document') as string);
|
||||
latex_data.set_main_document(file);
|
||||
return;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user