aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runtime/compiler/groff.vim45
-rw-r--r--runtime/doc/quickfix.txt11
2 files changed, 56 insertions, 0 deletions
diff --git a/runtime/compiler/groff.vim b/runtime/compiler/groff.vim
new file mode 100644
index 0000000000..640146d6a1
--- /dev/null
+++ b/runtime/compiler/groff.vim
@@ -0,0 +1,45 @@
+" Vim compiler file
+" Compiler: Groff
+" Maintainer: Konfekt
+" Last Change: 2024 Sep 8
+"
+" Expects output file extension, say `:make html` or `:make pdf`.
+" Supported devices as of Sept 2024 are: (x)html, pdf, ps, dvi, lj4, lbp ...
+" Adjust command-line flags, language, encoding by buffer-local/global variables
+" groff_compiler_args, groff_compiler_lang, and groff_compiler_encoding,
+" which default to '', &spelllang and 'utf8'.
+
+if exists("current_compiler")
+ finish
+endif
+
+let s:keepcpo = &cpo
+set cpo&vim
+
+let current_compiler = 'groff'
+
+silent! function s:groff_compiler_lang()
+ let lang = get(b:, 'groff_compiler_lang',
+ \ &spell ? matchstr(&spelllang, '^\a\a') : '')
+ if lang ==# 'en' | let lang = '' | endif
+ return empty(lang) ? '' : '-m'..lang
+endfunction
+
+" Requires output format (= device) to be set by user after :make.
+execute 'CompilerSet makeprg=groff'..escape(
+ \ ' '..s:groff_compiler_lang()..
+ \ ' -K'..get(b:, 'groff_compiler_encoding', get(g:, 'groff_compiler_encoding', 'utf8'))..
+ \ ' '..get(b:, 'groff_compiler_args', get(g:, 'groff_compiler_args', ''))..
+ \ ' -mom -T$* -- %:S > %:r:S.$*', ' ')
+" From Gavin Freeborn's https://github.com/Gavinok/vim-troff under Vim License
+" https://github.com/Gavinok/vim-troff/blob/91017b1423caa80aba541c997909a4f810edd275/compiler/troff.vim#L39
+CompilerSet errorformat=%o:<standard\ input>\ (%f):%l:%m,
+ \%o:\ <standard\ input>\ (%f):%l:%m,
+ \%o:%f:%l:%m,
+ \%o:\ %f:%l:%m,
+ \%f:%l:\ macro\ %trror:%m,
+ \%f:%l:%m,
+ \%W%tarning:\ file\ '%f'\\,\ around\ line\ %l:,%Z%m
+
+let &cpo = s:keepcpo
+unlet s:keepcpo
diff --git a/runtime/doc/quickfix.txt b/runtime/doc/quickfix.txt
index 30c84d7e8d..e408eb44f4 100644
--- a/runtime/doc/quickfix.txt
+++ b/runtime/doc/quickfix.txt
@@ -1294,6 +1294,17 @@ Commonly used compiler options can be added to 'makeprg' by setting the
g:javac_makeprg_params variable. For example: >
let g:javac_makeprg_params = "-Xlint:all -encoding utf-8"
<
+GROFF *quickfix-groff* *compiler-groff*
+
+The GROFF compiler plugin uses the mom macro set (documented in the groff_mom
+manpage) as input and expects that the output file type extension is passed to
+make, say :make html or :make pdf.
+
+Additional arguments can be passed to groff by setting them in
+`b:groff_compiler_args` or `g:groff_compiler_args`. The `language` argument
+passed to groff is set using 'spelllang'; it can be overridden by setting
+`b:groff_compiler_lang`. The default enconding is `UTF-8` and can be changed
+by setting `b:groff_compiler_encoding` or `g:groff_compiler_encoding`.
PANDOC *quickfix-pandoc* *compiler-pandoc*