groff.vim (1611B)
1 " Vim compiler file 2 " Compiler: Groff 3 " Maintainer: Konfekt 4 " Last Change: 2024 Nov 19 5 " 6 " Expects output file extension, say `:make html` or `:make pdf`. 7 " Supported devices as of Sept 2024 are: (x)html, pdf, ps, dvi, lj4, lbp ... 8 " Adjust command-line flags, language, encoding by buffer-local/global variables 9 " groff_compiler_args, groff_compiler_lang, and groff_compiler_encoding, 10 " which default to '', &spelllang and 'utf8'. 11 12 if exists("current_compiler") 13 finish 14 endif 15 16 let s:keepcpo = &cpo 17 set cpo&vim 18 19 let current_compiler = 'groff' 20 21 silent! function s:groff_compiler_lang() 22 let lang = get(b:, 'groff_compiler_lang', 23 \ &spell ? matchstr(&spelllang, '^\a\a') : '') 24 if lang ==# 'en' | let lang = '' | endif 25 return empty(lang) ? '' : '-m'..lang 26 endfunction 27 28 " Requires output format (= device) to be set by user after :make. 29 execute 'CompilerSet makeprg=groff'..escape( 30 \ ' '..s:groff_compiler_lang().. 31 \ ' -K'..get(b:, 'groff_compiler_encoding', get(g:, 'groff_compiler_encoding', 'utf8')).. 32 \ ' '..get(b:, 'groff_compiler_args', get(g:, 'groff_compiler_args', '')).. 33 \ ' -mom -T$* -- %:S > %:r:S.$*', ' \|"') 34 " From Gavin Freeborn's https://github.com/Gavinok/vim-troff under Vim License 35 " https://github.com/Gavinok/vim-troff/blob/91017b1423caa80aba541c997909a4f810edd275/compiler/troff.vim#L39 36 CompilerSet errorformat=%o:<standard\ input>\ (%f):%l:%m, 37 \%o:\ <standard\ input>\ (%f):%l:%m, 38 \%o:%f:%l:%m, 39 \%o:\ %f:%l:%m, 40 \%f:%l:\ macro\ %trror:%m, 41 \%f:%l:%m, 42 \%W%tarning:\ file\ '%f'\\,\ around\ line\ %l:,%Z%m 43 44 let &cpo = s:keepcpo 45 unlet s:keepcpo