Skip to content

Commit d30ffdc

Browse files
committed
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: #15642 Signed-off-by: Konfekt <[email protected]> Signed-off-by: Christian Brabandt <[email protected]>
1 parent 7cc0e91 commit d30ffdc

3 files changed

Lines changed: 18 additions & 13 deletions

File tree

.github/MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ runtime/compiler/jshint.vim @dkearns
7676
runtime/compiler/jsonlint.vim @dkearns
7777
runtime/compiler/jq.vim @vito-c
7878
runtime/compiler/lazbuild.vim @dkearns
79+
runtime/compiler/pandoc.vim @Konfekt
7980
runtime/compiler/perl.vim @petdance @heptite
8081
runtime/compiler/perlcritic.vim @petdance @dkearns
8182
runtime/compiler/php.vim @dkearns

runtime/compiler/pandoc.vim

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
" Vim compiler file
22
" Compiler: Pandoc
33
" Maintainer: Konfekt
4-
" Last Change: 2024 Aug 20
4+
" Last Change: 2024 Sep 8
55
"
66
" Expects output file extension, say `:make html` or `:make pdf`.
77
" Passes additional arguments to pandoc, say `:make html --self-contained`.
8+
" Adjust command-line flags by buffer-local/global variable
9+
" b/g:pandoc_compiler_args which defaults to empty.
810

911
if exists("current_compiler")
1012
finish
@@ -40,18 +42,21 @@ silent! function s:PandocFiletype(filetype) abort
4042
endif
4143
endfunction
4244

43-
let b:pandoc_compiler_from = get(b:, 'pandoc_compiler_from', s:PandocFiletype(&filetype))
44-
let b:pandoc_compiler_lang = get(b:, 'pandoc_compiler_lang', &spell ? matchstr(&spelllang, '^\a\a') : '')
45+
silent! function s:PandocLang()
46+
let lang = get(b:, 'pandoc_compiler_lang',
47+
\ &spell ? matchstr(&spelllang, '^\a\a') : '')
48+
if lang ==# 'en' | let lang = '' | endif
49+
return empty(lang) ? '' : '--metadata lang='..lang
50+
endfunction
4551

4652
execute 'CompilerSet makeprg=pandoc'..escape(
47-
\ ' --standalone' .
48-
\ (b:pandoc_compiler_from ==# 'markdown' && (getline(1) =~# '^%\s\+\S\+' || (search('^title:\s+\S+', 'cnw') > 0)) ?
49-
\ '' : ' --metadata title=%:t:r:S') .
50-
\ (empty(b:pandoc_compiler_lang) ?
51-
\ '' : ' --metadata lang='..b:pandoc_compiler_lang) .
52-
\ ' --from='..b:pandoc_compiler_from .
53-
\ ' '..get(b:, 'pandoc_compiler_args', get(g:, 'pandoc_compiler_args', '')) .
54-
\ ' --output %:r:S.$* -- %:S', ' ')
53+
\ ' --standalone'..
54+
\ (s:PandocFiletype(&filetype) ==# 'markdown' && (getline(1) =~# '^%\s\+\S\+' || (search('^title:\s+\S+', 'cnw') > 0)) ?
55+
\ '' : ' --metadata title=%:t:r:S')..
56+
\ ' '..s:PandocLang()..
57+
\ ' --from='..s:PandocFiletype(&filetype)..
58+
\ ' '..get(b:, 'pandoc_compiler_args', get(g:, 'pandoc_compiler_args', ''))..
59+
\ ' --output %:r:S.$* -- %:S', ' ')
5560
CompilerSet errorformat=\"%f\",\ line\ %l:\ %m
5661

5762
let &cpo = s:keepcpo

runtime/doc/quickfix.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1359,8 +1359,7 @@ Additional arguments can be passed to pandoc:
13591359

13601360
The `--from` argument is an educated guess using the buffer file type;
13611361
it can be overridden by setting `b:pandoc_compiler_from`.
1362-
Likewise the `--metadata lang` argument is set using `&spelllang`;
1363-
it can be overridden by setting `b:pandoc_compiler_lang`.
1362+
The `--metadata lang` argument is set using 'spelllang';
13641363
If `--from=markdown` is assumed and no title set in a title header or
13651364
YAML block, then the filename (without extension) is used as the title.
13661365

0 commit comments

Comments
 (0)