diff options
author | Christian Clason <c.clason@uni-graz.at> | 2024-09-11 09:20:34 +0200 |
---|---|---|
committer | Christian Clason <c.clason@uni-graz.at> | 2024-09-11 09:47:30 +0200 |
commit | def611111854612057421bb14f88ed161cfcb7f3 (patch) | |
tree | 2e532049587c76aaec43cbb872e963acd7ed29a4 | |
parent | 15bfdf73ea17e513edcec63be9ba27a5f4f12c7a (diff) | |
download | rneovim-def611111854612057421bb14f88ed161cfcb7f3.tar.gz rneovim-def611111854612057421bb14f88ed161cfcb7f3.tar.bz2 rneovim-def611111854612057421bb14f88ed161cfcb7f3.zip |
vim-patch:7cc0e91: 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: vim/vim#15646
https://github.com/vim/vim/commit/7cc0e9145dbd6b25de849b3c218e51fb689e6dfc
Co-authored-by: Konfekt <Konfekt@users.noreply.github.com>
-rw-r--r-- | runtime/compiler/groff.vim | 45 | ||||
-rw-r--r-- | runtime/doc/quickfix.txt | 11 |
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* |