robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

zeertzjqvim-patch:69075d3: runtime(compiler): Do not set title in pandoc compiler (#37347)ba7e17160d

master
2.2 KiB63 linesraw
1" Vim compiler file
2" Compiler:     Pandoc
3" Maintainer:   Konfekt
4" Last Change:	2024 Nov 19
5" 2025 May 15 by Vim Project: Update the title regex for CompilerSet #17321
6" 2026 Jan 10 by Vim Project: Do not set the title #19048
7"
8" Expects output file extension, say `:make html` or `:make pdf`.
9" Passes additional arguments to pandoc, say `:make html --self-contained`.
10" Adjust command-line flags by buffer-local/global variable
11" b/g:pandoc_compiler_args which defaults to empty.
12
13if exists("current_compiler")
14  finish
15endif
16
17let s:keepcpo = &cpo
18set cpo&vim
19
20let current_compiler = 'pandoc'
21
22" As of 2024-04-08 pandoc supports the following text input formats with
23" an ftplugin on Github:
24let s:supported_filetypes =
25      \ [ 'bibtex', 'markdown', 'creole', 'json', 'csv', 'tsv', 'docbook',
26      \   'xml', 'fb2', 'html', 'jira', 'tex', 'mediawiki', 'nroff', 'org',
27      \   'rtf', 'rst', 't2t', 'textile', 'twiki', 'typst', 'vimwiki' ]
28" .. and out of those the following are included in Vim's runtime:
29" 'xml', 'tex', 'html', 'rst', 'json', 'nroff', 'markdown'
30
31silent! function s:PandocFiletype(filetype) abort
32  let ft = a:filetype
33
34  if     ft ==# 'pandoc' | return 'markdown'
35  elseif ft ==# 'tex'    | return 'latex'
36  " Pandoc does not support XML as a generic input format, but it does support
37  " EndNote XML and Jats XML out of which the latter seems more universal.
38  elseif ft ==# 'xml'    | return 'jats'
39  elseif ft ==# 'text' || empty(ft)             | return 'markdown'
40  elseif index(s:supported_filetypes, &ft) >= 0 | return ft
41  else
42    echomsg 'Unsupported filetype: '..ft..', falling back to Markdown as input format!'
43    return 'markdown'
44  endif
45endfunction
46
47silent! function s:PandocLang()
48  let lang = get(b:, 'pandoc_compiler_lang',
49      \ &spell ? matchstr(&spelllang, '^\a\a') : '')
50  if lang ==# 'en' | let lang = '' | endif
51  return empty(lang) ? '' : '--metadata lang='..lang
52endfunction
53
54execute 'CompilerSet makeprg=pandoc'..escape(
55    \ ' --standalone'..
56    \ ' '..s:PandocLang()..
57    \ ' --from='..s:PandocFiletype(&filetype)..
58    \ ' '..get(b:, 'pandoc_compiler_args', get(g:, 'pandoc_compiler_args', ''))..
59    \ ' --output %:r:S.$* -- %:S', ' \|"')
60CompilerSet errorformat=\"%f\",\ line\ %l:\ %m
61
62let &cpo = s:keepcpo
63unlet s:keepcpo