Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
"stick this shit in a markdown ftplugin
"
"Usage:
"
"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()))
endif
endfunction
"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")
endfunction
function! s:CompileMdCmd() abort
return "marked -i " . expand("%:p") . " -o " . expand("%:p:r") . ".html"
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.