1
0
mirror of https://github.com/tiyn/dotfiles.git synced 2026-07-18 11:41:36 +02:00

Nvim: Updated knap to use working dynamic engine selection

This commit is contained in:
2026-07-17 07:18:46 +02:00
parent 52521ae0d1
commit 731ba1b0f4
2 changed files with 74 additions and 38 deletions

29
.local/bin/etc/nvim/compiler Executable file → Normal file
View File

@@ -27,13 +27,28 @@ has_python_version() {
textype() {
command="pdflatex --shell-escape"
(sed 5q "$file" | grep -i -q 'xelatex') && command="xelatex"
$command --output-directory="$dir" "$base" &&
grep -i addbibresource "$file" >/dev/null &&
biber --input-directory "$dir" "$base" &&
$command --output-directory="$dir" "$base" &&
makeglossaries "$basenodir" &&
$command --output-directory="$dir" "$base"
# Detect XeLaTeX from the first 15 lines. Supported forms include:
# % !TeX program = xelatex
# % xelatex
# and packages which require or commonly imply XeLaTeX.
if sed -n '1,15p' "$file" | grep -Eiq \
'(^%+[[:space:]]*!tex[[:space:]]+program[[:space:]]*=[[:space:]]*xelatex)|(^%+[[:space:]]*xelatex[[:space:]]*$)|(\\usepackage[^}]*\{(fontspec|unicode-math|mathspec)\})'; then
command="xelatex"
fi
$command --output-directory="$dir" "$base" || return 1
if grep -iq '\\addbibresource' "$file"; then
biber --input-directory "$dir" "$base" || return 1
$command --output-directory="$dir" "$base" || return 1
fi
if grep -iq '\\makeglossaries' "$file"; then
makeglossaries "$basenodir" || return 1
$command --output-directory="$dir" "$base" || return 1
fi
return 0
}
case "$file" in