add: cleanup script,
break: makeindex, changed: pdflatex command (no script)
This commit is contained in:
parent
2a47f9b5ef
commit
ec47895eb6
|
@ -59,6 +59,10 @@
|
||||||
"command": "latex.makeindex",
|
"command": "latex.makeindex",
|
||||||
"title": "makeindex",
|
"title": "makeindex",
|
||||||
"category": "LaTeX"
|
"category": "LaTeX"
|
||||||
|
}, {
|
||||||
|
"command": "latex.cleanup",
|
||||||
|
"title": "Cleanup directory (delete compile helper files)",
|
||||||
|
"category": "LaTeX"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"languages": [
|
"languages": [
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
cleanupDir=${1%/} # remove trailing / if necessary
|
||||||
|
|
||||||
|
echo $cleanupDir
|
||||||
|
|
||||||
|
if [ -d $cleanupDir ]; then # check if cleanupDir is a directory
|
||||||
|
cd $cleanupDir;
|
||||||
|
else
|
||||||
|
echo "Couldn't find directory to clean up"
|
||||||
|
fi
|
||||||
|
for file in $cleanupDir/*.*; do
|
||||||
|
if [ -f $file ]; then
|
||||||
|
for ending in "log" "ilg" "out" "toc" "aux" "synctex.gz" "idx" "ind"; do
|
||||||
|
if [[ $file == *.$ending ]]; then
|
||||||
|
rm "$file"
|
||||||
|
echo -e "\033[93m rm $file \033[0m"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
done
|
|
@ -1,23 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
FILEDIRNAME=${1%/*}
|
|
||||||
FILE=${1##*/}
|
|
||||||
echo "fileDirname : $FILEDIRNAME"
|
|
||||||
echo "file : $FILE"
|
|
||||||
|
|
||||||
if [ ${FILE: -4} == ".tex" ]; then
|
|
||||||
cd "$FILEDIRNAME"
|
|
||||||
pdflatex -synctex=1 -interaction=nonstopmode -output-directory="$FILEDIRNAME" "$FILE" > ~/.vscode/.pdflatex_log
|
|
||||||
if [ $? == 0 ]; then # check success status (return value) of the last command (pdflatex)
|
|
||||||
echo -e "\033[32mCreated \"${FILE%.*}.pdf\" successfully.\033[0m";
|
|
||||||
# lsof -- "${FILE%.*}.pdf" > /dev/null; # check if .pdf file if allready opened
|
|
||||||
# if [ $? != 0 ]; then
|
|
||||||
# ( nohup evince "${FILE%.*}.pdf" > /dev/null; exit; ) # open the created .pdf
|
|
||||||
# fi
|
|
||||||
else
|
|
||||||
cat ~/.vscode/.pdflatex_log
|
|
||||||
echo -e "\033[31mERROR: Compiling \"${FILE}\" failed.\033[0m";
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "$FILE is not a *.tex file."
|
|
||||||
fi
|
|
|
@ -1,5 +1,7 @@
|
||||||
import * as vscode from 'vscode';
|
import * as vscode from 'vscode';
|
||||||
import * as child_process from 'child_process';
|
import * as child_process from 'child_process';
|
||||||
|
import documentclass_symbols from '../dictionary/documentclass_symbols';
|
||||||
|
import { window } from 'vscode';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
// pdflatex -synctex=1 -interaction=nonstopmode -output-directory="$FILEDIRNAME" "$FILE" > ~/.vscode/.pdflatex_log
|
// pdflatex -synctex=1 -interaction=nonstopmode -output-directory="$FILEDIRNAME" "$FILE" > ~/.vscode/.pdflatex_log
|
||||||
|
@ -9,9 +11,10 @@ export default {
|
||||||
var fileDir: string = document.fileName.substring(0, document.fileName.lastIndexOf('/'));
|
var fileDir: string = document.fileName.substring(0, document.fileName.lastIndexOf('/'));
|
||||||
|
|
||||||
document.save(); // save the document before compile
|
document.save(); // save the document before compile
|
||||||
child_process.exec("pdflatex -synctex=1 -interaction=nonstopmode -output-directory=" + fileDir + " " + document.fileName,
|
child_process.exec(
|
||||||
|
"pdflatex -synctex=1 -interaction=nonstopmode -output-directory=" + fileDir + " " + document.fileName,
|
||||||
{ cwd: fileDir }, // set the working directory
|
{ cwd: fileDir }, // set the working directory
|
||||||
(error, stdout, stderr) => {
|
(error: Error, stdout: string, stderr: string) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
vscode.window.showErrorMessage("pdflatex Failed: " + error.message + ", " + stdout);
|
vscode.window.showErrorMessage("pdflatex Failed: " + error.message + ", " + stdout);
|
||||||
} else {
|
} else {
|
||||||
|
@ -20,29 +23,36 @@ export default {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
// latex_pdflatex: function latex_pdflatex(textEditor: vscode.TextEditor, textEditorEdit: vscode.TextEditorEdit): void {
|
|
||||||
// textEditor.document.save();
|
|
||||||
// child_process.exec(
|
|
||||||
// "echo $(" + this.extensionPath + "/scripts/pdflatex.sh \"" + textEditor.document.fileName + "\")",
|
|
||||||
// (error: Error, stdout: string, stderr: string) => {
|
|
||||||
// if (error) {
|
|
||||||
// vscode.window.showErrorMessage("pdflatex Failed: " + error.message + ", " + stdout);
|
|
||||||
// } else {
|
|
||||||
// vscode.window.setStatusBarMessage("Created File: " + textEditor.document.fileName.replace('.tex', '.pdf'), 5000);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// );
|
|
||||||
// },
|
|
||||||
latex_makeindex: function latex_makeindex(textEditor: vscode.TextEditor, textEditorEdit: vscode.TextEditorEdit): void {
|
latex_makeindex: function latex_makeindex(textEditor: vscode.TextEditor, textEditorEdit: vscode.TextEditorEdit): void {
|
||||||
textEditor.document.save();
|
var document: vscode.TextDocument = textEditor.document;
|
||||||
|
var fileDir: string = document.fileName.substring(0, document.fileName.lastIndexOf('/'));
|
||||||
|
|
||||||
|
textEditor.document.save(); // save the document before makeindex
|
||||||
child_process.exec(
|
child_process.exec(
|
||||||
"echo $(" + this.extensionPath + "/scripts/makeindex.sh \"" + textEditor.document.fileName + "\")",
|
"makeindex " + document.fileName.substring(0, document.fileName.lastIndexOf('.')) + ".idx",
|
||||||
|
{ cwd: fileDir }, // set the working directory
|
||||||
(error: Error, stdout: string, stderr: string) => {
|
(error: Error, stdout: string, stderr: string) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
vscode.window.showErrorMessage("makeindex Failed: " + error.message + ", " + stdout);
|
vscode.window.showErrorMessage("makeindex Failed: " + error.stack + ", " + stdout);
|
||||||
} else {
|
} else {
|
||||||
vscode.window.setStatusBarMessage("Index Created: " + textEditor.document.fileName.replace('.tex', '.idx'), 5000);
|
vscode.window.setStatusBarMessage("Index Created:", 5000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
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('/'));
|
||||||
|
|
||||||
|
child_process.execFile(
|
||||||
|
"./scripts/cleanup.sh",
|
||||||
|
[ fileDir ],
|
||||||
|
{ cwd: this.extensionPath }, // set the working directory
|
||||||
|
(error: Error, stdout: string, stderr: string) => {
|
||||||
|
if (error) {
|
||||||
|
vscode.window.showErrorMessage("cleanup Failed: " + error.message + ", " + stdout);
|
||||||
|
} else {
|
||||||
|
vscode.window.showInformationMessage(stdout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -20,6 +20,11 @@ export function activate(context: vscode.ExtensionContext) {
|
||||||
Commands.latex_makeindex,
|
Commands.latex_makeindex,
|
||||||
{ extensionPath: context.extensionPath }
|
{ extensionPath: context.extensionPath }
|
||||||
));
|
));
|
||||||
|
context.subscriptions.push(vscode.commands.registerTextEditorCommand(
|
||||||
|
'latex.cleanup',
|
||||||
|
Commands.latex_cleanup,
|
||||||
|
{ extensionPath: context.extensionPath }
|
||||||
|
));
|
||||||
|
|
||||||
// Register the Completion Item Provider
|
// Register the Completion Item Provider
|
||||||
context.subscriptions.push(vscode.languages.registerCompletionItemProvider(
|
context.subscriptions.push(vscode.languages.registerCompletionItemProvider(
|
||||||
|
|
Loading…
Reference in New Issue