X-Git-Url: https://git.sthu.org/?p=vimconf.git;a=blobdiff_plain;f=macros.vim;h=d74406055ece5b04f6c1184bcbfe2f7c9340adfd;hp=b33bf4da65992365e37c3886d23716cc993d43ce;hb=HEAD;hpb=fc796f75c5dc7a7d0fa7fb6d56a99b07caf4d270 diff --git a/macros.vim b/macros.vim index b33bf4d..1da3dae 100644 --- a/macros.vim +++ b/macros.vim @@ -78,9 +78,12 @@ endfunction function InsertIncludeGuardsWithoutEndif() - let gatename = substitute(expand("%:t"), "\\.", "_", "g") . '_' . strpart(system('pwgen -c 16 1'), 0, 16) - execute "normal! i#ifndef " . gatename - execute "normal! o#define " . gatename + " Build name of guard: Take filename, replace some chars by _ and + " prepend a random sequence to make guard robust against file name + " collisions. + let guardname = substitute(expand("%:t"), "[\\.-]", "_", "g") . '_' . strpart(system('pwgen -c 16 1'), 0, 16) + execute "normal! i#ifndef " . guardname + execute "normal! o#define " . guardname endfunction @@ -109,6 +112,15 @@ endfunction function RunAsciidoctor() execute ":!asciidoctor " . @% + if executable("asciidoctor-pdf") + execute ":!asciidoctor-pdf " . @% + elseif executable("asciidoctor") + execute ":!asciidoctor " . @% + endif +endfunction + +function RunAsciidoctorPdf() + execute ":!asciidoctor-pdf " . @% endfunction @@ -126,7 +138,9 @@ endfunction function RunAsciidoc() - if executable("asciidoctor") + if executable("asciidoctor-pdf") + call RunAsciidoctorPdf() + elseif executable("asciidoctor") call RunAsciidoctor() else echo "No asciidoc implementation found."