From d949d43432e6e812e7917f1220f825502e7d605c Mon Sep 17 00:00:00 2001 From: Klesh Wong Date: Wed, 25 Nov 2020 18:01:46 +0800 Subject: [PATCH] [misc] support groff_mom --- cli/vim/init.vim | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/cli/vim/init.vim b/cli/vim/init.vim index 76da5b9..c8767f3 100644 --- a/cli/vim/init.vim +++ b/cli/vim/init.vim @@ -127,6 +127,7 @@ if $VIM_MODE == 'enhanced' Plug 'rbgrouleff/bclose.vim' endif Plug 'puremourning/vimspector' + Plug 'vim-scripts/mom.vim' else Plug 'Vimjas/vim-python-pep8-indent', { 'for': 'python' } endif @@ -255,20 +256,30 @@ fu! NERDCommenter_after() endfu " ==== groff ==== -function! ToggleGroffAutoCompilation() - let g:GroffAutoCompilation = !get(g:, "GroffAutoCompilation", 0) +fu! SilentOK(cmd) + let l:ouput = system(substitute(a:cmd, "%", expand("%"), "g")) + if v:shell_error != 0 + echo ouput + endif +endfu + +fu! ToggleGroffMomAutoCompilation() + let g:GroffMomAutoCompilation = !get(g:, "GroffMomAutoCompilation", 0) augroup GroffPdf autocmd! augroup END - if g:GroffAutoCompilation + if g:GroffMomAutoCompilation augroup GroffPdf - autocmd BufWritePost,FileWritePost *.ms :silent !groff -Kutf8 -ms % -U > /tmp/tmp.ps && ps2pdf /tmp/tmp.ps %.pdf + autocmd BufWritePost,FileWritePost *.mom + :call SilentOK("groff -Kutf8 -mom % > /tmp/tmp.ps && ps2pdf /tmp/tmp.ps %.pdf") augroup END - echo "Auto compilation enabled" + echo "Auto compilation for groff_mom enabled" else - echo "Auto compilation disabled" + echo "Auto compilation for groff_mom disabled" endif -endfunction -nnoremap ac :call ToggleGroffAutoCompilation() +endfu +nnoremap ac :call ToggleGroffMomAutoCompilation() +autocmd BufEnter,BufRead *.mom :set ft=mom +