[misc] support groff_mom

This commit is contained in:
Klesh Wong 2020-11-25 18:01:46 +08:00
parent 2dd689bb67
commit d949d43432

View File

@ -127,6 +127,7 @@ if $VIM_MODE == 'enhanced'
Plug 'rbgrouleff/bclose.vim' Plug 'rbgrouleff/bclose.vim'
endif endif
Plug 'puremourning/vimspector' Plug 'puremourning/vimspector'
Plug 'vim-scripts/mom.vim'
else else
Plug 'Vimjas/vim-python-pep8-indent', { 'for': 'python' } Plug 'Vimjas/vim-python-pep8-indent', { 'for': 'python' }
endif endif
@ -255,20 +256,30 @@ fu! NERDCommenter_after()
endfu endfu
" ==== groff ==== " ==== groff ====
function! ToggleGroffAutoCompilation() fu! SilentOK(cmd)
let g:GroffAutoCompilation = !get(g:, "GroffAutoCompilation", 0) 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 augroup GroffPdf
autocmd! autocmd!
augroup END augroup END
if g:GroffAutoCompilation if g:GroffMomAutoCompilation
augroup GroffPdf 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 augroup END
echo "Auto compilation enabled" echo "Auto compilation for groff_mom enabled"
else else
echo "Auto compilation disabled" echo "Auto compilation for groff_mom disabled"
endif endif
endfunction endfu
nnoremap <leader>ac :call ToggleGroffAutoCompilation()<CR> nnoremap <leader>ac :call ToggleGroffMomAutoCompilation()<CR>
autocmd BufEnter,BufRead *.mom :set ft=mom