Skip to content

Commit 7cc0e91

Browse files
Konfektchrisbra
authored andcommitted
runtime(groff): Add compiler plugin for groff
Groff MOM (Macros for Manuscripts) is a macro package for the GNU troff (groff) typesetting system, a light-weight alternative to LaTeX for professional-quality documents. closes: #15646 Signed-off-by: Konfekt <[email protected]> Signed-off-by: Christian Brabandt <[email protected]>
1 parent c2285a8 commit 7cc0e91

4 files changed

Lines changed: 61 additions & 1 deletion

File tree

.github/MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ runtime/compiler/gawk.vim @dkearns
6565
runtime/compiler/gjs.vim @dkearns
6666
runtime/compiler/gm2.vim @dkearns
6767
runtime/compiler/go.vim @dbarnett
68+
runtime/compiler/groff.vim @Konfekt
6869
runtime/compiler/haml.vim @tpope
6970
runtime/compiler/hare.vim @selenebun
7071
runtime/compiler/icon.vim @dkearns

runtime/compiler/groff.vim

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
" Vim compiler file
2+
" Compiler: Groff
3+
" Maintainer: Konfekt
4+
" Last Change: 2024 Sep 8
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

runtime/doc/quickfix.txt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*quickfix.txt* For Vim version 9.1. Last change: 2024 Aug 20
1+
*quickfix.txt* For Vim version 9.1. Last change: 2024 Sep 09
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -1335,6 +1335,18 @@ If Vim was started from the compiler, the :sh and some :! commands will not
13351335
work, because Vim is then running in the same process as the compiler and
13361336
stdin (standard input) will not be interactive.
13371337

1338+
GROFF *quickfix-groff* *compiler-groff*
1339+
1340+
The GROFF compiler plugin uses the mom macro set (documented in the groff_mom
1341+
manpage) as input and expects that the output file type extension is passed to
1342+
make, say :make html or :make pdf.
1343+
1344+
Additional arguments can be passed to groff by setting them in
1345+
`b:groff_compiler_args` or `g:groff_compiler_args`. The `language` argument
1346+
passed to groff is set using 'spelllang'; it can be overridden by setting
1347+
`b:groff_compiler_lang`. The default enconding is `UTF-8` and can be changed
1348+
by setting `b:groff_compiler_encoding` or `g:groff_compiler_encoding`.
1349+
13381350
PANDOC *quickfix-pandoc* *compiler-pandoc*
13391351

13401352
The Pandoc compiler plugin expects that an output file type extension is

runtime/doc/tags

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6545,6 +6545,7 @@ compiler-decada ft_ada.txt /*compiler-decada*
65456545
compiler-dotnet quickfix.txt /*compiler-dotnet*
65466546
compiler-gcc quickfix.txt /*compiler-gcc*
65476547
compiler-gnat ft_ada.txt /*compiler-gnat*
6548+
compiler-groff quickfix.txt /*compiler-groff*
65486549
compiler-hpada ft_ada.txt /*compiler-hpada*
65496550
compiler-javac quickfix.txt /*compiler-javac*
65506551
compiler-manx quickfix.txt /*compiler-manx*
@@ -9640,6 +9641,7 @@ quickfix-directory-stack quickfix.txt /*quickfix-directory-stack*
96409641
quickfix-error-lists quickfix.txt /*quickfix-error-lists*
96419642
quickfix-functions usr_41.txt /*quickfix-functions*
96429643
quickfix-gcc quickfix.txt /*quickfix-gcc*
9644+
quickfix-groff quickfix.txt /*quickfix-groff*
96439645
quickfix-index quickfix.txt /*quickfix-index*
96449646
quickfix-manx quickfix.txt /*quickfix-manx*
96459647
quickfix-pandoc quickfix.txt /*quickfix-pandoc*

0 commit comments

Comments
 (0)