parent
ec47895eb6
commit
cdaaa6b7bf
12
package.json
12
package.json
|
@ -43,6 +43,18 @@
|
|||
"TeX"
|
||||
],
|
||||
"contributes": {
|
||||
"configuration":[
|
||||
{
|
||||
"title": "LaTeX extention Configuration",
|
||||
"properties": {
|
||||
"latex.shell": {
|
||||
"type": "string",
|
||||
"default": "\\bin\\bash",
|
||||
"description": "The shell to be used for child processes like the compile commands pdflatex or cleanup commands."
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"keybindings": [
|
||||
{
|
||||
"key": "ctrl+shift+b",
|
||||
|
|
|
@ -9,16 +9,22 @@ export default {
|
|||
latex_pdflatex: function latex_pdflatex(textEditor: vscode.TextEditor, textEditorEdit: vscode.TextEditorEdit): void {
|
||||
var document: vscode.TextDocument = textEditor.document;
|
||||
var fileDir: string = document.fileName.substring(0, document.fileName.lastIndexOf('/'));
|
||||
var outputChannel: vscode.OutputChannel = this.outputChannel;
|
||||
|
||||
outputChannel.clear(); // clear the outputChannel to only show the last output
|
||||
document.save(); // save the document before compile
|
||||
child_process.exec(
|
||||
"pdflatex -synctex=1 -interaction=nonstopmode -output-directory=" + fileDir + " " + document.fileName,
|
||||
"pdflatex -synctex=1 -interaction=nonstopmode -output-directory=\"" + fileDir + "\" \"" + document.fileName + "\"",
|
||||
{ cwd: fileDir }, // set the working directory
|
||||
(error: Error, stdout: string, stderr: string) => {
|
||||
if (error) {
|
||||
vscode.window.showErrorMessage("pdflatex Failed: " + error.message + ", " + stdout);
|
||||
vscode.window.showErrorMessage("pdflatex Failed: see output.");
|
||||
outputChannel.show();
|
||||
outputChannel.appendLine("pdflatex Failed: " + error.message);
|
||||
outputChannel.append(stdout + "\n" + stderr);
|
||||
} else {
|
||||
vscode.window.setStatusBarMessage("Created File: " + document.fileName.replace('.tex', '.pdf'), 5000);
|
||||
vscode.window.setStatusBarMessage("pdflatex succeeded: see output", 5000);
|
||||
outputChannel.appendLine("pdflatex succeeded: created file " + document.fileName.replace('.tex', '.pdf'));
|
||||
}
|
||||
}
|
||||
);
|
||||
|
@ -26,16 +32,21 @@ export default {
|
|||
latex_makeindex: function latex_makeindex(textEditor: vscode.TextEditor, textEditorEdit: vscode.TextEditorEdit): void {
|
||||
var document: vscode.TextDocument = textEditor.document;
|
||||
var fileDir: string = document.fileName.substring(0, document.fileName.lastIndexOf('/'));
|
||||
var outputChannel: vscode.OutputChannel = this.outputChannel;
|
||||
|
||||
textEditor.document.save(); // save the document before makeindex
|
||||
child_process.exec(
|
||||
"makeindex " + document.fileName.substring(0, document.fileName.lastIndexOf('.')) + ".idx",
|
||||
"makeindex " + document.fileName.substring(document.fileName.lastIndexOf('/') + 1, document.fileName.lastIndexOf('.')),
|
||||
{ cwd: fileDir }, // set the working directory
|
||||
(error: Error, stdout: string, stderr: string) => {
|
||||
if (error) {
|
||||
vscode.window.showErrorMessage("makeindex Failed: " + error.stack + ", " + stdout);
|
||||
vscode.window.showErrorMessage("makeindex Failed: see output.");
|
||||
outputChannel.show();
|
||||
outputChannel.appendLine("makeindex Failed: " + error.message);
|
||||
outputChannel.append(stdout + "\n" + stderr);
|
||||
} else {
|
||||
vscode.window.setStatusBarMessage("Index Created:", 5000);
|
||||
vscode.window.setStatusBarMessage("makeindex succeeded", 5000);
|
||||
outputChannel.appendLine("makeindex succeeded: created *.ind file\n" + stdout);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
@ -43,16 +54,29 @@ export default {
|
|||
latex_cleanup: function latex_cleanup(textEditor: vscode.TextEditor, textEditorEdit: vscode.TextEditorEdit): void {
|
||||
var document: vscode.TextDocument = textEditor.document;
|
||||
var fileDir: string = document.fileName.substring(0, document.fileName.lastIndexOf('/'));
|
||||
var fileName: string = document.fileName.substring(document.fileName.lastIndexOf('/') + 1, document.fileName.lastIndexOf('.'));
|
||||
var outputChannel: vscode.OutputChannel = this.outputChannel;
|
||||
|
||||
child_process.execFile(
|
||||
"./scripts/cleanup.sh",
|
||||
[ fileDir ],
|
||||
{ cwd: this.extensionPath }, // set the working directory
|
||||
child_process.exec("\
|
||||
for file in \"" + fileName + "\".*; do \
|
||||
for end in \"aux\" \"idx\" \"ilg\" \"ind\" \"log\" \"out\" \"toc\" \"synctex.gz\"; do \
|
||||
if [[ \"$file\" == *.\"$end\" ]]; then \
|
||||
rm \"$file\"; \
|
||||
echo removed: \"$file\"; \
|
||||
fi; \
|
||||
done; \
|
||||
done;",
|
||||
{ cwd: fileDir, shell: this.settings["latex.shell"] },
|
||||
(error: Error, stdout: string, stderr: string) => {
|
||||
if (error) {
|
||||
vscode.window.showErrorMessage("cleanup Failed: " + error.message + ", " + stdout);
|
||||
vscode.window.showErrorMessage("cleanup Failed: see output.");
|
||||
outputChannel.show();
|
||||
outputChannel.appendLine("cleanup Failed: " + error.message);
|
||||
outputChannel.append(stdout + "\n" + stderr);
|
||||
} else {
|
||||
vscode.window.showInformationMessage(stdout);
|
||||
vscode.window.setStatusBarMessage("cleanup succeeded", 5000);
|
||||
outputChannel.appendLine('Directory "' + fileDir + '" cleaned');
|
||||
outputChannel.append(stdout);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
|
|
@ -7,23 +7,26 @@ import Commands from './commands';
|
|||
// this method is called when your extension is activated
|
||||
// your extension is activated the very first time the command is executed
|
||||
export function activate(context: vscode.ExtensionContext) {
|
||||
var outputChannel: vscode.OutputChannel = vscode.window.createOutputChannel("LaTeX build output");
|
||||
var settings: vscode.WorkspaceConfiguration = vscode.workspace.getConfiguration('latex');
|
||||
|
||||
// Register Build Commands
|
||||
// The Command was defined in package.json and the commandId parameter has
|
||||
// to be equal to the 'command' field in the package.json file
|
||||
context.subscriptions.push(vscode.commands.registerTextEditorCommand(
|
||||
'latex.pdflatex',
|
||||
Commands.latex_pdflatex,
|
||||
{ extensionPath: context.extensionPath }
|
||||
{ extensionPath: context.extensionPath, outputChannel: outputChannel, settings: settings }
|
||||
));
|
||||
context.subscriptions.push(vscode.commands.registerTextEditorCommand(
|
||||
'latex.makeindex',
|
||||
Commands.latex_makeindex,
|
||||
{ extensionPath: context.extensionPath }
|
||||
{ extensionPath: context.extensionPath, outputChannel: outputChannel, settings: settings }
|
||||
));
|
||||
context.subscriptions.push(vscode.commands.registerTextEditorCommand(
|
||||
'latex.cleanup',
|
||||
Commands.latex_cleanup,
|
||||
{ extensionPath: context.extensionPath }
|
||||
{ extensionPath: context.extensionPath, outputChannel: outputChannel, settings: settings }
|
||||
));
|
||||
|
||||
// Register the Completion Item Provider
|
||||
|
|
Loading…
Reference in New Issue