aboutsummaryrefslogtreecommitdiff
path: root/runtime/compiler/groff.vim
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2024-11-19 22:57:13 +0000
committerJosh Rahm <joshuarahm@gmail.com>2024-11-19 22:57:13 +0000
commit9be89f131f87608f224f0ee06d199fcd09d32176 (patch)
tree11022dcfa9e08cb4ac5581b16734196128688d48 /runtime/compiler/groff.vim
parentff7ed8f586589d620a806c3758fac4a47a8e7e15 (diff)
parent88085c2e80a7e3ac29aabb6b5420377eed99b8b6 (diff)
downloadrneovim-9be89f131f87608f224f0ee06d199fcd09d32176.tar.gz
rneovim-9be89f131f87608f224f0ee06d199fcd09d32176.tar.bz2
rneovim-9be89f131f87608f224f0ee06d199fcd09d32176.zip
Merge remote-tracking branch 'upstream/master' into mix_20240309
Diffstat (limited to 'runtime/compiler/groff.vim')
-rw-r--r--runtime/compiler/groff.vim45
1 files changed, 45 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