Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
"stick this shit in a markdown ftplugin
"Open a markdown file.
"Use the :MdLive command.
"Save the file and it will update
command MdLive call s:InitMarkdownHacks()
autocmd bufwritepost <buffer> call s:CheckToBuildMd()
"compile current MD file if it is THE ONE we are focused on
function! s:CheckToBuildMd() abort
if exists("g:markdown_autobuild_buf") && g:markdown_autobuild_buf == bufnr("")
call jobstart(system(s:CompileMdCmd()))
"select current buffer as THE ONE
"kill any open mdlive procs
"spawn new mdlive proc for current buf
function! s:InitMarkdownHacks() abort
let g:markdown_autobuild_buf = bufnr("")
"seems dodgy as fuck
call system("killall mdlive")
call system(s:CompileMdCmd())
call system("mdlive " . expand("%:p:r") . ".html")
function! s:CompileMdCmd() abort
return "marked -i " . expand("%:p") . " -o " . expand("%:p:r") . ".html"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment