mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:d30ffdc: runtime(pandoc): Update compiler plugin to use actual 'spelllang'
Previously these would be cached in buffer-local variables and
would not change on :compiler pandoc
closes: vim/vim#15642
d30ffdca49
Co-authored-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
parent
def6111118
commit
830cf054bc
@ -1,10 +1,12 @@
|
|||||||
" Vim compiler file
|
" Vim compiler file
|
||||||
" Compiler: Pandoc
|
" Compiler: Pandoc
|
||||||
" Maintainer: Konfekt
|
" Maintainer: Konfekt
|
||||||
" Last Change: 2024 Aug 20
|
" Last Change: 2024 Sep 8
|
||||||
"
|
"
|
||||||
" Expects output file extension, say `:make html` or `:make pdf`.
|
" Expects output file extension, say `:make html` or `:make pdf`.
|
||||||
" Passes additional arguments to pandoc, say `:make html --self-contained`.
|
" Passes additional arguments to pandoc, say `:make html --self-contained`.
|
||||||
|
" Adjust command-line flags by buffer-local/global variable
|
||||||
|
" b/g:pandoc_compiler_args which defaults to empty.
|
||||||
|
|
||||||
if exists("current_compiler")
|
if exists("current_compiler")
|
||||||
finish
|
finish
|
||||||
@ -40,18 +42,21 @@ silent! function s:PandocFiletype(filetype) abort
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
let b:pandoc_compiler_from = get(b:, 'pandoc_compiler_from', s:PandocFiletype(&filetype))
|
silent! function s:PandocLang()
|
||||||
let b:pandoc_compiler_lang = get(b:, 'pandoc_compiler_lang', &spell ? matchstr(&spelllang, '^\a\a') : '')
|
let lang = get(b:, 'pandoc_compiler_lang',
|
||||||
|
\ &spell ? matchstr(&spelllang, '^\a\a') : '')
|
||||||
|
if lang ==# 'en' | let lang = '' | endif
|
||||||
|
return empty(lang) ? '' : '--metadata lang='..lang
|
||||||
|
endfunction
|
||||||
|
|
||||||
execute 'CompilerSet makeprg=pandoc'..escape(
|
execute 'CompilerSet makeprg=pandoc'..escape(
|
||||||
\ ' --standalone' .
|
\ ' --standalone'..
|
||||||
\ (b:pandoc_compiler_from ==# 'markdown' && (getline(1) =~# '^%\s\+\S\+' || (search('^title:\s+\S+', 'cnw') > 0)) ?
|
\ (s:PandocFiletype(&filetype) ==# 'markdown' && (getline(1) =~# '^%\s\+\S\+' || (search('^title:\s+\S+', 'cnw') > 0)) ?
|
||||||
\ '' : ' --metadata title=%:t:r:S') .
|
\ '' : ' --metadata title=%:t:r:S')..
|
||||||
\ (empty(b:pandoc_compiler_lang) ?
|
\ ' '..s:PandocLang()..
|
||||||
\ '' : ' --metadata lang='..b:pandoc_compiler_lang) .
|
\ ' --from='..s:PandocFiletype(&filetype)..
|
||||||
\ ' --from='..b:pandoc_compiler_from .
|
\ ' '..get(b:, 'pandoc_compiler_args', get(g:, 'pandoc_compiler_args', ''))..
|
||||||
\ ' '..get(b:, 'pandoc_compiler_args', get(g:, 'pandoc_compiler_args', '')) .
|
\ ' --output %:r:S.$* -- %:S', ' ')
|
||||||
\ ' --output %:r:S.$* -- %:S', ' ')
|
|
||||||
CompilerSet errorformat=\"%f\",\ line\ %l:\ %m
|
CompilerSet errorformat=\"%f\",\ line\ %l:\ %m
|
||||||
|
|
||||||
let &cpo = s:keepcpo
|
let &cpo = s:keepcpo
|
||||||
|
@ -1318,8 +1318,7 @@ Additional arguments can be passed to pandoc:
|
|||||||
|
|
||||||
The `--from` argument is an educated guess using the buffer file type;
|
The `--from` argument is an educated guess using the buffer file type;
|
||||||
it can be overridden by setting `b:pandoc_compiler_from`.
|
it can be overridden by setting `b:pandoc_compiler_from`.
|
||||||
Likewise the `--metadata lang` argument is set using `&spelllang`;
|
The `--metadata lang` argument is set using 'spelllang';
|
||||||
it can be overridden by setting `b:pandoc_compiler_lang`.
|
|
||||||
If `--from=markdown` is assumed and no title set in a title header or
|
If `--from=markdown` is assumed and no title set in a title header or
|
||||||
YAML block, then the filename (without extension) is used as the title.
|
YAML block, then the filename (without extension) is used as the title.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user