Skip to content

Commit fa5cbe4

Browse files
committed
feat: add error message when compile bad mainfile
refer: #2465
1 parent c035255 commit fa5cbe4

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

autoload/vimtex/compiler.vim

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,14 @@ endfunction
187187

188188
" }}}1
189189
function! vimtex#compiler#start() abort " {{{1
190+
if b:vimtex.main_parser ==# 'fallback current file'
191+
call vimtex#log#error(
192+
\ 'Compilation error due to failed mainfile detection!',
193+
\ 'Please ensure that VimTeX can locate the proper main .tex file.',
194+
\ 'Read ":help vimtex-multi-file" for more info.'
195+
\)
196+
return
197+
endif
190198
if b:vimtex.compiler.is_running()
191199
call vimtex#log#warning(
192200
\ 'Compiler is already running for `' . b:vimtex.base . "'")

autoload/vimtex/state.vim

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ endfunction
1414

1515
" }}}1
1616
function! vimtex#state#init() abort " {{{1
17-
let [l:main, l:main_type] = s:get_main()
17+
let [l:main, l:main_parser] = s:get_main()
1818
let l:id = s:get_main_id(l:main)
1919

2020
if l:id >= 0
2121
let b:vimtex_id = l:id
2222
let b:vimtex = s:vimtex_states[l:id]
2323
else
2424
let b:vimtex_id = s:vimtex_next_id
25-
let b:vimtex = vimtex#state#class#new(l:main, l:main_type, 0)
25+
let b:vimtex = vimtex#state#class#new(l:main, l:main_parser, 0)
2626
let s:vimtex_next_id += 1
2727
let s:vimtex_states[b:vimtex_id] = b:vimtex
2828
endif
@@ -268,7 +268,7 @@ function! s:get_main() abort " {{{1
268268
return [expand('%:p'), 'bib file']
269269
endif
270270
else
271-
return [expand('%:p'), 'current file']
271+
return [expand('%:p'), 'fallback current file']
272272
endif
273273
endfunction
274274

0 commit comments

Comments
 (0)