blob: 3e9ae0488fc4e29357d900f8969596324db98227 [file] [log] [blame]
Konfekt7cc0e912024-09-09 20:03:03 +02001" Vim compiler file
2" Compiler: Groff
3" Maintainer: Konfekt
Konfekt4927dae2024-11-19 22:41:14 +01004" Last Change: 2024 Nov 19
Konfekt7cc0e912024-09-09 20:03:03 +02005"
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
12if exists("current_compiler")
13 finish
14endif
15
16let s:keepcpo = &cpo
17set cpo&vim
18
19let current_compiler = 'groff'
20
21silent! 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
26endfunction
27
28" Requires output format (= device) to be set by user after :make.
29execute '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', ''))..
Konfekt4927dae2024-11-19 22:41:14 +010033 \ ' -mom -T$* -- %:S > %:r:S.$*', ' \|"')
Konfekt7cc0e912024-09-09 20:03:03 +020034" 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
36CompilerSet 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
44let &cpo = s:keepcpo
45unlet s:keepcpo