Add pandoc/rmarkdown compilation shortcuts to vim

This commit is contained in:
Marty Oehme 2019-12-04 10:27:57 +01:00
parent faf0542563
commit eb88925501
3 changed files with 17 additions and 6 deletions

View file

@ -232,5 +232,7 @@ nnoremap <silent> <localleader>cm :CiteMarkdown<cr>
" p to comPile a document (or file, works for some languages like go/python/c)
" o to open the resulting document (mostly for pdfs)
nnoremap <localleader>o :!open-compiled <c-r>%<CR><CR>
nnoremap <localleader>p :w! \| !compile <c-r>%<CR>
" P to comPile *and* open a doc
nnoremap <localleader>po :CompileOpen<cr>
nnoremap <localleader>pp :CompileDoc<cr>
nnoremap <localleader>PP :CompileDocAndOpen<cr>

View file

@ -28,7 +28,7 @@ case "$file" in
*\.ms) refer -PS -e "$file" | groff -me -ms -kept -T pdf >"$base".pdf ;;
*\.mom) refer -PS -e "$file" | groff -mom -kept -T pdf >"$base".pdf ;;
*\.[0-9]) refer -PS -e "$file" | groff -mandoc -T pdf >"$base".pdf ;;
*\.rmd | *\.md | *\.mkd | *\.markdown) echo "require(rmarkdown); render('$file')" | R -q --vanilla ;;
*\.[Rr]md | *\.md | *\.mkd | *\.markdown) echo "require(rmarkdown); render('$file')" | R -q --vanilla ;;
*\.tex) textype "$file" ;;
*config.h) sudo make install ;;
*\.c) cc "$file" -o "$base" && "$base" ;;

View file

@ -8,8 +8,17 @@
basename="$(echo "$1" | sed 's/\.[^\/.]*$//')"
openCompiledDoc() {
if [ -f "$basename".pdf ]; then
setsid "$FILEREADER" "$basename.pdf"
elif [ -f "$basename".html ]; then
setsid "$BROWSER" "$basename.html"
fi
}
case "$1" in
*.tex|*.md|*.rmd|*.ms|*.me|*.mom) setsid "$FILEREADER" "$basename".pdf >/dev/null 2>&1 & ;;
*.[0-9]) setsid "$FILEREADER" "$basename".pdf >/dev/null 2>&1 & ;;
*.html) setsid "$BROWSER" "$basename".html >/dev/null 2>&1 & ;;
# *.tex|*.md|*.rmd|*.ms|*.me|*.mom) setsid "$FILEREADER" "$basename".pdf >/dev/null 2>&1 & ;;
*.tex|*.md|*.[Rr]md|*.ms|*.me|*.mom) openCompiledDoc >/dev/null 2>&1 & ;;
*.[0-9]) openCompiledDoc >/dev/null 2>&1 & ;;
*.html) openCompiledDoc >/dev/null 2>&1 & ;;
esac