groff.vim 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. " Vim compiler file
  2. " Compiler: Groff
  3. " Maintainer: Konfekt
  4. " Last Change: 2024 Nov 19
  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. if exists("current_compiler")
  12. finish
  13. endif
  14. let s:keepcpo = &cpo
  15. set cpo&vim
  16. let current_compiler = 'groff'
  17. silent! function s:groff_compiler_lang()
  18. let lang = get(b:, 'groff_compiler_lang',
  19. \ &spell ? matchstr(&spelllang, '^\a\a') : '')
  20. if lang ==# 'en' | let lang = '' | endif
  21. return empty(lang) ? '' : '-m'..lang
  22. endfunction
  23. " Requires output format (= device) to be set by user after :make.
  24. execute 'CompilerSet makeprg=groff'..escape(
  25. \ ' '..s:groff_compiler_lang()..
  26. \ ' -K'..get(b:, 'groff_compiler_encoding', get(g:, 'groff_compiler_encoding', 'utf8'))..
  27. \ ' '..get(b:, 'groff_compiler_args', get(g:, 'groff_compiler_args', ''))..
  28. \ ' -mom -T$* -- %:S > %:r:S.$*', ' \|"')
  29. " From Gavin Freeborn's https://github.com/Gavinok/vim-troff under Vim License
  30. " https://github.com/Gavinok/vim-troff/blob/91017b1423caa80aba541c997909a4f810edd275/compiler/troff.vim#L39
  31. CompilerSet errorformat=%o:<standard\ input>\ (%f):%l:%m,
  32. \%o:\ <standard\ input>\ (%f):%l:%m,
  33. \%o:%f:%l:%m,
  34. \%o:\ %f:%l:%m,
  35. \%f:%l:\ macro\ %trror:%m,
  36. \%f:%l:%m,
  37. \%W%tarning:\ file\ '%f'\\,\ around\ line\ %l:,%Z%m
  38. let &cpo = s:keepcpo
  39. unlet s:keepcpo