diff --git a/nvim/.config/nvim/maps.vim b/nvim/.config/nvim/maps.vim index 28f2ad6..e3ca78c 100644 --- a/nvim/.config/nvim/maps.vim +++ b/nvim/.config/nvim/maps.vim @@ -242,9 +242,13 @@ nnoremap cc :CiteRef " map cm to insert markdown prettified citation nnoremap cm :CiteMarkdown -" p to comPile a document (or file, works for some languages like go/python/c) +" pp to comPile a document (or file, works for some languages like go/python/c) " o to open the resulting document (mostly for pdfs) -" P to comPile *and* open a doc -nnoremap po :CompileOpen -nnoremap pp :CompileDoc -nnoremap PP :CompileDocAndOpen +" po to comPile *and* open a doc +" and all the same in uppercase for verbose output +nnoremap pp :DocCompile +nnoremap PP :DocCompile! +nnoremap po :DocCompileOpen +nnoremap PO :DocCompileOpen! +nnoremap o :DocOpen +nnoremap O :DocOpen! diff --git a/nvim/.config/nvim/plugin/compiledoc.vim b/nvim/.config/nvim/plugin/compiledoc.vim deleted file mode 100644 index 5e4310f..0000000 --- a/nvim/.config/nvim/plugin/compiledoc.vim +++ /dev/null @@ -1,22 +0,0 @@ -function CompileDoc() - :execute(":w!") - :execute(":!compile \"%\"") -endfunction - -function CompileDocNoOutput() - :execute(":w!") - :execute(":silent !compile \"%\"") -endfunction - -function CompiledOpen() - :execute(":silent !open-compiled \"%\"") -endfunction - -function CompileDocAndOpen() - call CompileDocNoOutput() - call CompiledOpen() -endfunction - -command CompileDoc call CompileDoc() -command CompileOpen call CompiledOpen() -command CompileDocAndOpen call CompileDocAndOpen() diff --git a/nvim/.config/nvim/plugin/personal/doccompile.vim b/nvim/.config/nvim/plugin/personal/doccompile.vim new file mode 100644 index 0000000..0170a38 --- /dev/null +++ b/nvim/.config/nvim/plugin/personal/doccompile.vim @@ -0,0 +1,25 @@ +function s:_compile(verbose, ...) + :execute(":w!") + if a:verbose + execute "!" . "compile" . " " . "%" . " " . join(a:000) + else + silent "!" . "compile" . " " . "%" . " " . join(a:000) + endif +endfunction + +function s:_open(verbose, ...) + if a:verbose + execute "!" . "open-compiled" . " " . "%" . " " . join(a:000) + else + silent "!" . "open-compiled" . " " . "%" . " " . join(a:000) + endif +endfunction + +function s:_compileopen(verbose, ...) + call s:_compile(0, ) + call s:_open(0, ) +endfunction + +command -bang -nargs=* DocCompile call s:_compile(0, ) +command -bang -nargs=* DocCompileOpen call s:_compileopen(0, ) +command -bang -nargs=* DocOpen call s:_open(0, ) diff --git a/scripts/.local/bin/compile b/scripts/.local/bin/compile index 375adea..1dd0e5d 100755 --- a/scripts/.local/bin/compile +++ b/scripts/.local/bin/compile @@ -7,8 +7,18 @@ # # Compiles .tex. groff (.mom, .ms), .rmd, .md. Opens .sent files as sent # presentations. Runs scripts based on extention or shebang +# +# Expects the file to compile as first argument. +# Desired output format(s) can be specified in optional arguments following. file=$(readlink -f "$1") +printf "file: %s\n" "$file" + +if [ "$#" -gt 1 ]; then + shift + formats="$*" +fi + dir=$(dirname "$file") base="${file%.*}" @@ -28,14 +38,17 @@ textype() { } sendtoRmd() { - ifinstalled R && echo "require(rmarkdown); render('$1')" | R -q --vanilla + # v removed for too much magic that can break; simply input pdf_document if you want it + # formats=$(echo "$formats" | perl -pe 's/([\w-]+)(?"$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 ;; -*\.[Rr]md | *\.md | *\.mkd | *\.markdown) sendtoRmd "$file" ;; +*\.[Rr]md | *\.md | *\.mkd | *\.markdown) sendtoRmd "$file" "$formats" ;; *\.tex) textype "$file" ;; *config.h) sudo make install ;; *\.c) cc "$file" -o "$base" && "$base" ;;