diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-09-19 04:05:19 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-09-19 04:05:19 +0000 |
commit | a4e9136f68a40b1cb0eb6df5a5f06603224a87f4 (patch) | |
tree | ba32e0d0069ad6adfd6b32d05161a03eea5e4c7c /runtime/compiler | |
parent | Releasing progress-linux version 2:9.1.0496-1~progress7.99u1. (diff) | |
download | vim-a4e9136f68a40b1cb0eb6df5a5f06603224a87f4.tar.xz vim-a4e9136f68a40b1cb0eb6df5a5f06603224a87f4.zip |
Merging upstream version 2:9.1.0698.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'runtime/compiler')
-rw-r--r-- | runtime/compiler/pandoc.vim | 45 | ||||
-rw-r--r-- | runtime/compiler/typst.vim | 15 |
2 files changed, 39 insertions, 21 deletions
diff --git a/runtime/compiler/pandoc.vim b/runtime/compiler/pandoc.vim index 6c15193..ecc935a 100644 --- a/runtime/compiler/pandoc.vim +++ b/runtime/compiler/pandoc.vim @@ -1,6 +1,7 @@ " Vim compiler file " Compiler: Pandoc " Maintainer: Konfekt +" Last Change: 2024 Aug 20 " " Expects output file extension, say `:make html` or `:make pdf`. " Passes additional arguments to pandoc, say `:make html --self-contained`. @@ -25,31 +26,33 @@ let s:supported_filetypes = silent! function s:PandocFiletype(filetype) abort let ft = a:filetype - if ft ==# 'pandoc' - return 'markdown' - elseif ft ==# 'tex' - return 'latex' - elseif ft ==# 'xml' - " Pandoc does not support XML as a generic input format, but it does support - " EndNote XML and Jats XML out of which the latter seems more universal. - return 'jats' - elseif ft ==# 'text' || empty(ft) - return 'markdown' - elseif index(s:supported_filetypes, &ft) >= 0 - return ft + + if ft ==# 'pandoc' | return 'markdown' + elseif ft ==# 'tex' | return 'latex' + " Pandoc does not support XML as a generic input format, but it does support + " EndNote XML and Jats XML out of which the latter seems more universal. + elseif ft ==# 'xml' | return 'jats' + elseif ft ==# 'text' || empty(ft) | return 'markdown' + elseif index(s:supported_filetypes, &ft) >= 0 | return ft else - echomsg 'Unsupported filetype: ' . ft . ', falling back to Markdown as input format!' + echomsg 'Unsupported filetype: '..ft..', falling back to Markdown as input format!' return 'markdown' endif endfunction -execute 'CompilerSet makeprg=pandoc\ --standalone' . - \ '\ --metadata\ title=%:t:r:S' . - \ '\ --metadata\ lang=' . matchstr(&spelllang, '^\a\a') . - \ '\ --from=' . s:PandocFiletype(&filetype) . - \ '\ ' . escape(get(b:, 'pandoc_compiler_args', get(g:, 'pandoc_compiler_args', '')), ' ') . - \ '\ --output\ %:r:S.$*\ %:S' - -CompilerSet errorformat="%f",\ line\ %l:\ %m + +let b:pandoc_compiler_from = get(b:, 'pandoc_compiler_from', s:PandocFiletype(&filetype)) +let b:pandoc_compiler_lang = get(b:, 'pandoc_compiler_lang', &spell ? matchstr(&spelllang, '^\a\a') : '') + +execute 'CompilerSet makeprg=pandoc'..escape( + \ ' --standalone' . + \ (b:pandoc_compiler_from ==# 'markdown' && (getline(1) =~# '^%\s\+\S\+' || (search('^title:\s+\S+', 'cnw') > 0)) ? + \ '' : ' --metadata title=%:t:r:S') . + \ (empty(b:pandoc_compiler_lang) ? + \ '' : ' --metadata lang='..b:pandoc_compiler_lang) . + \ ' --from='..b:pandoc_compiler_from . + \ ' '..get(b:, 'pandoc_compiler_args', get(g:, 'pandoc_compiler_args', '')) . + \ ' --output %:r:S.$* -- %:S', ' ') +CompilerSet errorformat=\"%f\",\ line\ %l:\ %m let &cpo = s:keepcpo unlet s:keepcpo diff --git a/runtime/compiler/typst.vim b/runtime/compiler/typst.vim new file mode 100644 index 0000000..33e5581 --- /dev/null +++ b/runtime/compiler/typst.vim @@ -0,0 +1,15 @@ +" Vim compiler file +" Language: Typst +" Maintainer: Gregory Anders +" Last Change: 2024-07-14 +" Based on: https://github.com/kaarmu/typst.vim + +if exists('current_compiler') + finish +endif +let current_compiler = get(g:, 'typst_cmd', 'typst') + +" With `--diagnostic-format` we can use the default errorformat +let s:makeprg = [current_compiler, 'compile', '--diagnostic-format', 'short', '%:S'] + +execute 'CompilerSet makeprg=' . join(s:makeprg, '\ ') |