add: Compile Commands

This commit is contained in:
Daniel Kapla 2018-01-07 14:44:53 +01:00
parent 8bce5ac877
commit 2a47f9b5ef
14 changed files with 591 additions and 407 deletions

View File

@ -0,0 +1,10 @@
import { latex_types } from "./symbol_types";
export default {
article: { documentation: "for articles, the most commonly used class", kind: latex_types.environment },
report: { documentation: "variant of article for a report", kind: latex_types.environment },
letter: { documentation: "for letters", kind: latex_types.environment },
book: { documentation: "for chapters of a book", kind: latex_types.environment },
proc: { documentation: "for proceedings, based on article", kind: latex_types.environment },
slides: { documentation: "to produce transparencies", kind: latex_types.environment },
};

View File

@ -1,50 +1,65 @@
import { latex_types } from "./symbol_types";
export default {
"displaymath": { insertText: "displaymath", details: "math environment", documentation: "displaymath", kind: latex_types.environment },
"align": { insertText: "align", details: "math environment", documentation: "align", kind: latex_types.environment },
"align*": { insertText: "align*", details: "math environment", documentation: "align*", kind: latex_types.environment },
"flalign": { insertText: "flalign", details: "math environment", documentation: "flalign", kind: latex_types.environment },
"flalign*": { insertText: "flalign*", details: "math environment", documentation: "flalign*", kind: latex_types.environment },
"gather": { insertText: "gather", details: "math environment", documentation: "gather", kind: latex_types.environment },
"gather*": { insertText: "gather*", details: "math environment", documentation: "gather*", kind: latex_types.environment },
"equation": { insertText: "equation", details: "math environment", documentation: "equation", kind: latex_types.environment },
"multline": { insertText: "multline", details: "math environment", documentation: "multline", kind: latex_types.environment },
"split": { insertText: "split", details: "math environment", documentation: "split", kind: latex_types.environment },
displaymath: { insertText: "displaymath", detail: "math environment", documentation: "displaymath", kind: latex_types.environment },
align: { insertText: "align", detail: "math environment", documentation: "align", kind: latex_types.environment },
"align*": { insertText: "align*", detail: "math environment", documentation: "align*", kind: latex_types.environment },
flalign: { insertText: "flalign", detail: "math environment", documentation: "flalign", kind: latex_types.environment },
"flalign*": { insertText: "flalign*", detail: "math environment", documentation: "flalign*", kind: latex_types.environment },
gather: { insertText: "gather", detail: "math environment", documentation: "gather", kind: latex_types.environment },
"gather*": { insertText: "gather*", detail: "math environment", documentation: "gather*", kind: latex_types.environment },
equation: { insertText: "equation", detail: "math environment", documentation: "equation", kind: latex_types.environment },
multline: { insertText: "multline", detail: "math environment", documentation: "multline", kind: latex_types.environment },
split: { insertText: "split", detail: "math environment", documentation: "split", kind: latex_types.environment },
"itemize": { insertText: "itemize", detail: "Use \\item for list entrie", documentation: "Creates a simple List.", kind: latex_types.environment },
"enumerate": { insertText: "enumerate", detail: "Use \\item for list entrie", documentation: "Creates a numbered List.", kind: latex_types.environment },
"description": { insertText: "description", detail: "Use \\item[element] for a discription entrie", documentation: "Creates a List of \"element\" discriptions.", kind: latex_types.environment },
minipage: { insertText: "minipage", detail: "\\begin{minipage}[<pos>]{<width>} ... \\end{minipage}", documentation: "minipage", kind: latex_types.environment },
"flushleft": { insertText: "flushleft", documentation: "Alignes Text left.", kind: latex_types.environment },
"flusright": { insertText: "flusright", documentation: "Alignes Text right.", kind: latex_types.environment },
"center": { insertText: "center", documentation: "Alignes Text centered.", kind: latex_types.environment },
itemize: { insertText: "itemize", detail: "Use \\item for list entrie", documentation: "Creates a simple List.", kind: latex_types.environment },
enumerate: { insertText: "enumerate", detail: "Use \\item for list entrie", documentation: "Creates a numbered List.", kind: latex_types.environment },
description: { insertText: "description", detail: "Use \\item[element] for a discription entrie", documentation: "Creates a List of \"element\" discriptions.", kind: latex_types.environment },
"quotation": { insertText: "quotation", documentation: "The quotation environment is useful for longer quotes going over several paragraphs, because it indents the first line of each paragraph.", kind: latex_types.environment },
"verse": { insertText: "verse", documentation: "The verse environment is useful for poems where the line breaks are important. The lines are separated by issuing a \\\\ at the end of a line and an empty line after each verse.", kind: latex_types.environment },
"abstract": { insertText: "abstract", documentation: "An environment for an abstract.", kind: latex_types.environment },
flushleft: { insertText: "flushleft", documentation: "Alignes Text left.", kind: latex_types.environment },
flusright: { insertText: "flusright", documentation: "Alignes Text right.", kind: latex_types.environment },
center: { insertText: "center", documentation: "Alignes Text centered.", kind: latex_types.environment },
"tikzpicture": { insertText: "tikzpicture", documentation: "The \"TeX Ist Kein Zeichnprogram\" environment\nNeeds \\usepackage{tikz}", kind: latex_types.environment },
quotation: { insertText: "quotation", documentation: "The quotation environment is useful for longer quotes going over several paragraphs, because it indents the first line of each paragraph.", kind: latex_types.environment },
verse: { insertText: "verse", documentation: "The verse environment is useful for poems where the line breaks are important. The lines are separated by issuing a \\\\ at the end of a line and an empty line after each verse.", kind: latex_types.environment },
abstract: { insertText: "abstract", documentation: "An environment for an abstract.", kind: latex_types.environment },
"verbatim": { insertText: "verbatim", detail: "Do not use verbatim environment and the \\verb command within parameters of other commands.", documentation: "Environment content will be directly printed, as if typed on a typewriter, with all line breaks and spaces, without any LaTeX command being executed.", kind: latex_types.environment },
tikzpicture: { insertText: "tikzpicture", documentation: "The \"TeX Ist Kein Zeichnprogram\" environment\nNeeds \\usepackage{tikz}", kind: latex_types.environment },
verbatim: { insertText: "verbatim", detail: "Do not use verbatim environment and the \\verb command within parameters of other commands.", documentation: "Environment content will be directly printed, as if typed on a typewriter, with all line breaks and spaces, without any LaTeX command being executed.", kind: latex_types.environment },
"verbatim*": { insertText: "verbatim*", detail: "Do not use verbatim environment and the \\verb command within parameters of other commands.", documentation: "Environment content will be directly printed, as if typed on a typewriter, with all line breaks and spaces, without any LaTeX command being executed. The additional * lets spaces be printed visible.", kind: latex_types.environment },
"tabular": { insertText: "tabular", detail: "Use \"&\" for jump to the next column, \"\\\\\" for a line break and \"\\hline\" for inserts a horizontal line", documentation: "The table spec argument of the \\begin{tabular}[pos]{table spec} command defines the format of the table. Use an \"l\" for a column of left-aligned text, \"r\" for right-aligned text, and \"c\" for centred text; p{width} for a column containing justified text with line breaks, and \"|\" for a vertical line. The pos argument specifies the vertical position of the table relative to the baseline of the surrounding text. Use either of the letters \"t\", \"b\" or \"c\" to specify table alignment at the top, bottom or center. The column separator can be specified with the @{...} construct. This command kills the inter-column space and replaces it with whatever is between the curly braces.", kind: latex_types.environment },
tabular: { insertText: "tabular", detail: "Use \"&\" for jump to the next column, \"\\\\\" for a line break and \"\\hline\" for inserts a horizontal line", documentation: "The table spec argument of the \\begin{tabular}[pos]{table spec} command defines the format of the table. Use an \"l\" for a column of left-aligned text, \"r\" for right-aligned text, and \"c\" for centred text; p{width} for a column containing justified text with line breaks, and \"|\" for a vertical line. The pos argument specifies the vertical position of the table relative to the baseline of the surrounding text. Use either of the letters \"t\", \"b\" or \"c\" to specify table alignment at the top, bottom or center. The column separator can be specified with the @{...} construct. This command kills the inter-column space and replaces it with whatever is between the curly braces.", kind: latex_types.environment },
"figure": { insertText: "figure", documentation: "Any material enclosed in a \"figure\" or \"table\" environment will be treated as floating matter. Both float environments support an optional parameter called the placement specifier. The placement specifier is a combination of \"h\" \(hier\), \"b\" \(bottom\), \"p\" \(page\), \"!\" \(without considering most of the internal parameters\)].", kind: latex_types.environment },
figure: { documentation: "Any material enclosed in a \"figure\" or \"table\" environment will be treated as floating matter. Both float environments support an optional parameter called the placement specifier. The placement specifier is a combination of \"h\" \(hier\), \"b\" \(bottom\), \"p\" \(page\), \"!\" \(without considering most of the internal parameters\)].", kind: latex_types.environment },
"cases": { insertText: "cases", documentation: "cases", kind: latex_types.environment },
cases: { documentation: "cases", kind: latex_types.environment },
"array": { insertText: "array", documentation: "The \\\\begin{array}{line-positioning} command with \"line-positioning\" is \"l\" \(left\), \"c\" \(richt\) or \"r\" \(right\) for each column. Use \"&\" to for next column and \"\\\\\" for linebreaks.", kind: latex_types.environment },
"matrix": { insertText: "matrix", detail: "max 10 column", documentation: "Matrix without delimiters.", kind: latex_types.environment },
"pmatrix": { insertText: "pmatrix", detail: "max 10 column", documentation: "Matrix with \( as delimiters.", kind: latex_types.environment },
"bmatrix": { insertText: "bmatrix", detail: "max 10 column", documentation: "Matrix with [ as delimiters.", kind: latex_types.environment },
"Bmatrix": { insertText: "Bmatrix", detail: "max 10 column", documentation: "Matrix with { as delimiters.", kind: latex_types.environment },
"vmatrix": { insertText: "vmatrix", detail: "max 10 column", documentation: "Matrix with | as delimiters.", kind: latex_types.environment },
"Vmatrix": { insertText: "Vmatrix", detail: "max 10 column", documentation: "Matrix with || as delimiters.", kind: latex_types.environment },
array: { documentation: "The \\\\begin{array}{line-positioning} command with \"line-positioning\" is \"l\" \(left\), \"c\" \(richt\) or \"r\" \(right\) for each column. Use \"&\" to for next column and \"\\\\\" for linebreaks.", kind: latex_types.environment },
matrix: { detail: "max 10 column", documentation: "Matrix without delimiters.", kind: latex_types.environment },
pmatrix: { detail: "max 10 column", documentation: "Matrix with \( as delimiters.", kind: latex_types.environment },
bmatrix: { detail: "max 10 column", documentation: "Matrix with [ as delimiters.", kind: latex_types.environment },
Bmatrix: { detail: "max 10 column", documentation: "Matrix with { as delimiters.", kind: latex_types.environment },
vmatrix: { detail: "max 10 column", documentation: "Matrix with | as delimiters.", kind: latex_types.environment },
Vmatrix: { detail: "max 10 column", documentation: "Matrix with || as delimiters.", kind: latex_types.environment },
"tizkpicture": { insertText: "tizkpicture", detail: "Requires Package \"tikz\"", documentation: "", kind: latex_types.environment },
tizkpicture: { insertText: "tizkpicture", detail: "Requires Package \"tikz\"", documentation: "", kind: latex_types.environment },
lstlisting: { insertText: "lstlisting", detail: "Requires Package \"listings\"", documentation: "", kind: latex_types.environment },
rmfamily: { documentation: "Font: Roman.", kind: latex_types.environment },
itshape: { documentation: "Font: Italics.", kind: latex_types.environment },
mdseries: { documentation: "Font: Medium weight (default).", kind: latex_types.environment },
bfseries: { documentation: "Font: Boldface.", kind: latex_types.environment },
upshape: { documentation: "Font: Upright (default).", kind: latex_types.environment },
slshape: { documentation: "Font: Slanted.", kind: latex_types.environment },
sffamily: { documentation: "Font: Sans serif.", kind: latex_types.environment },
scshape: { documentation: "Font: Small caps.", kind: latex_types.environment },
ttfamily: { documentation: "Font: Typewriter.", kind: latex_types.environment },
normalfont: { documentation: "Font: Main document font.", kind: latex_types.environment },
"lstlisting": { insertText: "lstlisting", detail: "Requires Package \"listings\"", documentation: "", kind: latex_types.environment },
};

View File

@ -4,7 +4,14 @@ var required_latexsym = "Required package \"latexsym\"";
var required_amsmath = "Required package \"amsmath\"";
export default {
"operatorname": { insertText: "operatorname{$1}$0", documentation: "displays content as operator", kind: latex_types.function },
begin: {
detail: "\\begin{<environment>} ... \\end{<environment>}",
insertText: "begin{$1}\n\t$0\n\\end{$1}",
documentation: "Environment Snippet",
kind: latex_types.snippet
},
operatorname: { insertText: "operatorname{$1}$0", documentation: "displays content as operator", kind: latex_types.function },
"label": { insertText: "label{$1}$0", documentation: "Creates a reference with a number to refere it by the \"ref\" command.", kind: latex_types.keyword },
"tag": { insertText: "tag{$1}$0", documentation: "Creates a reference with name to refere it by the \"ref\" command by the taged name.", kind: latex_types.keyword },
@ -26,8 +33,9 @@ export default {
"cfrac": { insertText: "cfrac{$1}{$2}$0", documentation: "Continued Fraction", kind: latex_types.function },
"tfrac": { insertText: "tfrac{$1}{$2}$0", documentation: "Text style Fraction", kind: latex_types.function },
"dfrac": { insertText: "dfrac{$1}{$2}$0", documentation: "Display style Fraction", kind: latex_types.function },
"genfrac": { insertText: "\genfrac{${1:left-delim}}{${2:right-delim}}{${3:thickness}}{${4:mathstyle}}{${5:numerator}}{${6:denominator}}$0", documentation: "Generic Fraction", kind: latex_types.function },
"sqrt": { insertText: "sqrt[]{$1}$0", documentation: "Root (Square Root)", kind: latex_types.function },
"genfrac": { insertText: "\\genfrac{${1:left-delim}}{${2:right-delim}}{${3:thickness}}{${4:mathstyle}}{${5:numerator}}{${6:denominator}}$0", documentation: "Generic Fraction", detail: "\\genfrac{<left-delim>}{<right-delim>}{<thickness>}{<mathstyle>}{<numerator>}{<denominator>}", kind: latex_types.function },
"sqrt": { insertText: "sqrt{$1}$0", documentation: "square root", kind: latex_types.function },
"sqrt[]": { insertText: "sqrt[]{$1}$0", detail: "\\sqrt[<n>]{<expr>}", documentation: "The <n>-th root of <expr>.", kind: latex_types.function },
"lim": { insertText: "lim_{$1}$0", documentation: "Limes", kind: latex_types.function },
"sup": { insertText: "sup_{$1}$0", documentation: "sup", kind: latex_types.function },

View File

@ -225,7 +225,6 @@ var node_options = {
};
export default {
node: node_options,
coordinate: node_options,
@ -239,6 +238,8 @@ export default {
clip: path_options,
useasboundingbox: path_options,
plot: path_options,
"begin{figure}": {
"!": { documentation: "overwrite" },
"h": { documentation: "hier" },

View File

@ -1,6 +1,13 @@
import { latex_types } from "./symbol_types";
export default {
begin: {
detail: "\\begin{<environment>} ... \\end{<environment>}",
insertText: "begin{$1}\n\t$0\n\\end{$1}",
documentation: "Environment Snippet",
kind: latex_types.snippet
},
input: {
detail: "\\input{<filename>}",
insertText: "input{${0:<filename>}}",
@ -25,6 +32,12 @@ export default {
documentation: "Allows to include raw ASCII text into your document as if it was inside a verbatim environment.",
kind: latex_types.keyword
},
lstinputlisting: {
detail: "\\lstinputlisting{<filename>}\nRequired package \"lstlisting\"",
insertText: "lstinputlisting{${0:<filename>}}",
documentation: "Allows to include Source Code.",
kind: latex_types.keyword
},
"usepackage": { insertText: "usepackage{$1}", documentation: "usepackage", kind: latex_types.keyword },
"newenvironment": { insertText: "newenvironment{${1:name}}[$2]{$3}{$0}", documentation: "newenvironment", kind: latex_types.keyword },
@ -58,11 +71,28 @@ export default {
"pageref": { insertText: "pageref{$1}$0", documentation: "Page reference", kind: latex_types.keyword },
"index": { insertText: "index{$1}$0", documentation: "Creates a index Entrie", kind: latex_types.keyword },
"emph": { insertText: "emph{$1}$0", documentation: "Emphasize Text", kind: latex_types.function },
"texttt": { insertText: "texttt{$1}$0", documentation: "Typeset Text", kind: latex_types.function },
"textit": { insertText: "textit{$1}$0", documentation: "Italic Text", kind: latex_types.function },
"textbf": { insertText: "textbf{$1}$0", documentation: "Bold Text", kind: latex_types.function },
"underline": { insertText: "underline{$1}$0", documentation: "Bold Text", kind: latex_types.function },
emph: { insertText: "emph{$1}$0", documentation: "Emphasize Text", kind: latex_types.function },
underline: { insertText: "underline{$1}$0", documentation: "Bold Text", kind: latex_types.function },
textrm: { insertText: "textrm{$1}$0", documentation: "Font: Roman", kind: latex_types.function },
rmfamily: { detail: "{\\rmfamily ... }", documentation: "Font: Roman", kind: latex_types.keyword },
textit: { insertText: "textit{$1}$0", documentation: "Font: Italic", kind: latex_types.function },
itshape: { detail: "{\\itshape ... }", documentation: "Font: Italic", kind: latex_types.keyword },
textmd: { insertText: "textmd{$1}$0", documentation: "Font: Medium weight", kind: latex_types.function },
mdseries: { detail: "{\\mdseries ... }", documentation: "Font: Medium weight", kind: latex_types.keyword },
textbf: { insertText: "textbf{$1}$0", documentation: "Font: Boldface", kind: latex_types.function },
bfseries: { detail: "{\\bfseries ... }", documentation: "Font: Boldface", kind: latex_types.keyword },
textup: { insertText: "textup{$1}$0", documentation: "Font: Upright", kind: latex_types.function },
upshape: { detail: "{\\upshape ... }", documentation: "Font: Upright", kind: latex_types.keyword },
textsl: { insertText: "textsl{$1}$0", documentation: "Font: Slanted", kind: latex_types.function },
slshape: { detail: "{\\slshape ... }", documentation: "Font: Slanted", kind: latex_types.keyword },
textsf: { insertText: "textsf{$1}$0", documentation: "Font: Sans serif", kind: latex_types.function },
sffamily: { detail: "{\\sffamily ... }", documentation: "Font: Sans serif", kind: latex_types.keyword },
textsc: { insertText: "textsc{$1}$0", documentation: "Font: Small caps", kind: latex_types.function },
scshape: { detail: "{\\scshape ... }", documentation: "Font: Small caps", kind: latex_types.keyword },
texttt: { insertText: "texttt{$1}$0", documentation: "Font: Typewriter", kind: latex_types.function },
ttfamily: { detail: "{\\ttfamily ... }", documentation: "Font: Typewriter", kind: latex_types.keyword },
textnormal: { insertText: "textnormal{$1}$0", documentation: "Font: Normal", kind: latex_types.function },
normalfont: { detail: "{\\normalfont ... }", documentation: "Font: Normal", kind: latex_types.keyword },
// TODO: need a specific type in different environments!!!
"centering": { insertText: "centering", documentation: "Centers the content of figure or minipage content", kind: latex_types.keyword },

View File

@ -34,7 +34,15 @@ export default {
draw: {
documentation: "Inside {tikzpicture} this is an abbreviation for \path[draw].",
kind: latex_types.keyword,
additionalInserts: [ { label: "draw[<options>]", insertText: "draw[${1:<options>}] $0", kind: latex_types.snippet } ]
additionalInserts: [ {
label: "draw[<options>]",
insertText: "draw[${1:<options>}] $0",
kind: latex_types.snippet
}, {
label: "draw plot",
insertText: "draw[${1:<options>}, domain=${2:<from>}:${3:<to>}] plot (\\x, {${4:<f(\\x)>}});$0",
kind: latex_types.snippet
} ]
},
fill: {
documentation: "Inside {tikzpicture} this is an abbreviation for \path[fill].",

View File

@ -43,20 +43,36 @@
"TeX"
],
"contributes": {
"keybindings": [
{
"key": "ctrl+shift+b",
"command": "latex.pdflatex",
"when": "editorLangId == 'latex'"
}
],
"commands": [
{
"command": "latex.pdflatex",
"title": "pdflatex",
"category": "LaTeX"
}, {
"command": "latex.makeindex",
"title": "makeindex",
"category": "LaTeX"
}
],
"languages": [
{
"id": "bibtex",
"aliases": [ "BibTeX" ],
"extensions": [ ".bib" ],
"configuration": "./settings/BibTeX-configuration.json"
},
{
}, {
"id": "latex",
"aliases": [ "LaTeX" ],
"extensions": [ "bbx", "cbx", "cls", "ltx", "lco", "sty", "tex", "tikz" ],
"configuration": "./settings/LaTeX-configuration.json"
},
{
}, {
"id": "tex",
"aliases": [ "TeX" ],
"extensions": [ "dtx", "ins" ],
@ -68,13 +84,11 @@
"language": "bibtex",
"scopeName": "text.bibtex",
"path": "./grammars/BibTeX.json"
},
{
}, {
"language": "latex",
"scopeName": "text.tex.latex",
"path": "./grammars/LaTeX.json"
},
{
}, {
"language": "tex",
"scopeName": "text.tex",
"path": "./grammars/TeX.json"

20
scripts/makeindex.sh Executable file
View File

@ -0,0 +1,20 @@
#!/bin/bash
FILEDIRNAME=$1
FILE=$2
echo "fileDirname : $FILEDIRNAME"
echo "file : $FILE"
if [ ${FILE: -4} == ".tex" ]; then
cd "$FILEDIRNAME"
FILE=${FILE##*/} # remove directory path from filename
makeindex "${FILE%.tex}.idx" > ~/.vscode/.makeindex_log # ${FILE%.tex}.idx replaces .tex ending with .idx
if [ $? == 0 ]; then # check success status (return value) of the last command (pdflatex)
echo -e "\033[32mCreated \"${FILE%.*}.idx\" successfully.\033[0m";
else
cat ~/.vscode/.makeindex_log
echo -e "\033[31mERROR: Make Index for \"${FILE}\" failed.\033[0m";
fi
else
echo "$FILE is not a *.tex file."
fi

23
scripts/pdflatex.sh Executable file
View File

@ -0,0 +1,23 @@
#!/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

View File

@ -1,13 +1,13 @@
{
"begin-end": {
"prefix": "\\begin",
"body": [
"\\begin{${1:displaymath}}",
"\t$0",
"\\end{$1}"
],
"description": "A Begin/End Block"
},
// "begin-end": {
// "prefix": "\\begin",
// "body": [
// "\\begin{${1:displaymath}}",
// "\t$0",
// "\\end{$1}"
// ],
// "description": "A Begin/End Block"
// },
"environment_tikz": {
"prefix": "environment_tikz",
"body": [

50
src/commands.ts Normal file
View File

@ -0,0 +1,50 @@
import * as vscode from 'vscode';
import * as child_process from 'child_process';
export default {
// pdflatex -synctex=1 -interaction=nonstopmode -output-directory="$FILEDIRNAME" "$FILE" > ~/.vscode/.pdflatex_log
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('/'));
document.save(); // save the document before compile
child_process.exec("pdflatex -synctex=1 -interaction=nonstopmode -output-directory=" + fileDir + " " + document.fileName,
{ cwd: fileDir }, // set the working directory
(error, stdout, stderr) => {
if (error) {
vscode.window.showErrorMessage("pdflatex Failed: " + error.message + ", " + stdout);
} else {
vscode.window.setStatusBarMessage("Created File: " + document.fileName.replace('.tex', '.pdf'), 5000);
}
}
);
},
// 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 {
textEditor.document.save();
child_process.exec(
"echo $(" + this.extensionPath + "/scripts/makeindex.sh \"" + textEditor.document.fileName + "\")",
(error: Error, stdout: string, stderr: string) => {
if (error) {
vscode.window.showErrorMessage("makeindex Failed: " + error.message + ", " + stdout);
} else {
vscode.window.setStatusBarMessage("Index Created: " + textEditor.document.fileName.replace('.tex', '.idx'), 5000);
}
}
);
}
}

View File

@ -5,6 +5,7 @@ import text_symbols from '../dictionary/text_symbols';
import math_symbols from '../dictionary/math_symbols';
import package_symbols from '../dictionary/package_symbols';
import environment_symbols from '../dictionary/environment_symbols';
import documentclass_symbols from '../dictionary/documentclass_symbols';
import tikz_symbols from '../dictionary/tikz_symbols';
import parameter_dictionary from '../dictionary/parameter_dictionary';
@ -93,6 +94,7 @@ export default class Provider implements vscode.CompletionItemProvider {
private text_symbols: vscode.CompletionItem[];
private math_symbols: vscode.CompletionItem[];
private package_symbols: vscode.CompletionItem[];
private documentclass_symbols: vscode.CompletionItem[];
private environment_symbols: vscode.CompletionItem[];
private tikz_symbols: vscode.CompletionItem[];
@ -112,6 +114,7 @@ export default class Provider implements vscode.CompletionItemProvider {
this.math_symbols = new Array<vscode.CompletionItem>();
this.package_symbols = new Array<vscode.CompletionItem>();
this.environment_symbols = new Array<vscode.CompletionItem>();
this.documentclass_symbols = new Array<vscode.CompletionItem>();
this.tikz_symbols = new Array<vscode.CompletionItem>();
// fill the collections from the LaTeX symbols definitions
fillSymbols(this.preamble_symbols, preamble_symbols);
@ -119,6 +122,7 @@ export default class Provider implements vscode.CompletionItemProvider {
fillSymbols(this.math_symbols, math_symbols);
fillSymbols(this.package_symbols, package_symbols);
fillSymbols(this.environment_symbols, environment_symbols);
fillSymbols(this.documentclass_symbols, documentclass_symbols);
fillSymbols(this.tikz_symbols, tikz_symbols);
this.parameter_dictionary = parameter_dictionary;
}
@ -222,21 +226,6 @@ export default class Provider implements vscode.CompletionItemProvider {
return filtert_symbols;
}
// // var p: Promise<string> = new Promise (function (resolve: (str: string) => void, reject: (str: string) => void) {
// // const argumentOfThen: string = "hello from Promise";
// // resolve(argumentOfThen);
// // }).then((result) => {
// // return result;
// // });
// /**
// * Encapsulates results from syncrone calculations in a promise and passes them throuw immediately
// * @param result The return value from .then's function
// */
// private promiseResult(result: vscode.CompletionItem[]): Thenable<vscode.CompletionItem[]> {
// return new Promise<vscode.CompletionItem[]>((resolve, reject) => { resolve(result); }).then((res) => res);
// }
private getFileNames(path: string, resolve: (completionItems: vscode.CompletionItem[]) => void, reject: (message: string) => void): void {
child_process.exec("ls " + path + " -t", (error: Error, stdout: string, stderr: string) => {
var fileNames = stdout.split("\n");
@ -257,15 +246,13 @@ export default class Provider implements vscode.CompletionItemProvider {
var line_text = line.text;
var line_before_pos = line_text.substring(0, position.character).trim();
var start_index: number;
var end_index: number;
var symbol_lable: string;
var symbol_parameter: string;
var start_index, end_index: number;
var symbol_lable, symbol_parameter: string;
if ((start_index = line_before_pos.lastIndexOf("\\") + 1) > 0) {
if ((end_index = line_before_pos.indexOf("{", start_index)) > -1) {
symbol_lable = line_before_pos.substring(start_index, end_index);
symbol_parameter = line_before_pos.substring(end_index + 1);
if ((end_index = symbol_lable.indexOf("[")) > -1) { // check for optional symbol parameters and ignore them if present
if ((end_index = symbol_lable.indexOf("[")) > -1) { // check for optional symbol parameters and ignore them
symbol_lable = symbol_lable.substring(0, end_index);
}
switch (symbol_lable) {
@ -278,9 +265,12 @@ export default class Provider implements vscode.CompletionItemProvider {
return resolve(this.searchAndCreateLableSymbols(document, symbol_parameter, position));
case "usepackage": // provide package symbols by first all usepackage parameters before the last ","
return resolve(this.filterSymbols(this.package_symbols, symbol_parameter.substring(symbol_parameter.lastIndexOf(",") + 1).trim(), position));
case "documentclass":
return resolve(this.filterSymbols(this.documentclass_symbols, symbol_parameter, position));
case "input":
case "include":
case "includegraphics":
case "lstinputlisting":
return this.getFileNames(symbol_parameter, resolve, reject); // runs async -> let getFileNames resolve / reject the promise
default: // default to NO suggestions
return resolve([]);

View File

@ -2,13 +2,28 @@
// Import the module and reference it with the alias vscode in your code below
import * as vscode from 'vscode';
import CompletionItemProvider from './completionItemProvider';
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) {
// 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 }
));
context.subscriptions.push(vscode.commands.registerTextEditorCommand(
'latex.makeindex',
Commands.latex_makeindex,
{ extensionPath: context.extensionPath }
));
// Register the Completion Item Provider
context.subscriptions.push(vscode.languages.registerCompletionItemProvider(
[{ language: 'latex'}], // document selector
[{ language: 'latex' }], // document selector
new CompletionItemProvider(), // A Complete Item Provider instance
'\\', '{', '[' //, '=' // Characters to trigger an completion suggestion
));