Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

callback fails after compilation success or saving the .tex file #2386

Closed
roao opened this issue May 7, 2022 · 15 comments
Closed

callback fails after compilation success or saving the .tex file #2386

roao opened this issue May 7, 2022 · 15 comments
Labels

Comments

@roao
Copy link

roao commented May 7, 2022

Description

Recently, I returned to write latex with vimtex, but I find I can't write latex with vimtex as before, because the callback doesn't work after compilation or saving the .tex file. I can callback mannually by :echo vimtex#comiler#callback(2), but I prefer it can callback automatically, just like previous. What happened in the newest vimtex?
I can reproduce the bug with example test file: minimal.vim and minimal.tex .
After compilation, when I can open minimal.pdf savely, the cmdline of neovim remains unchanged as show in image unless I type new commands in cmdline:

image

Steps to reproduce

No response

Expected behavior

No response

Actual behavior

No response

Do you use a latexmkrc file?

no

VimtexInfo

System info:
  OS: 61F-THINKPAD (Microsoft Windows 10 专业版)
  Vim version: NVIM v0.7.0
  Has clientserver: true
  Servername: \\.\pipe\nvim-15048-0

VimTeX project: minimal
  base: minimal.tex
  root: C:\Users\61F\Desktop\shishi
  tex: C:\Users\61F\Desktop\shishi\minimal.tex
  main parser: current file verified
  document class: minimal
  compiler: latexmk
    engine: -pdf
    options:
      -verbose
      -file-line-error
      -synctex=1
      -interaction=nonstopmode
    callback: 1
    continuous: 1
    executable: latexmk
    job: 
      jobid: 6
      output: C:\Users\61F\AppData\Local\Temp\nvimzePWKl\0
      cmd: set max_print_line=2000 & latexmk -verbose -file-line-error -synctex=1 -interaction=nonstopmode -pdf -pvc -view=none -e "$compiling_cmd = ($compiling_cmd ? $compiling_cmd . ' ^& ' : '') . 'echo vimtex_compiler_callback_compiling'" -e "$success_cmd = ($success_cmd ? $success_cmd . ' ^& ' : '') . 'echo vimtex_compiler_callback_success'" -e "$failure_cmd = ($failure_cmd ? $failure_cmd . ' ^& ' : '') . 'echo vimtex_compiler_callback_failure'" "minimal.tex"
      pid: 3016
  viewer: General
  qf method: LaTeX logfile
@roao roao added the bug label May 7, 2022
@lervag
Copy link
Owner

lervag commented May 8, 2022

It is impossible to answer your questions without more context.

Recently, I returned to write latex with vimtex, but I find I can't write latex with vimtex as before, because the callback doesn't work after compilation or saving the .tex file.

It should work as before, I can't think of a reason why it should not.

What happened in the newest vimtex?

You can check the release notes for some info, or read the git log.

Perhaps you could try to do a git bisect on your side to find which commit breaks things for you?

I can reproduce the bug with example test file: minimal.vim and minimal.tex .

You did not provide the test files. Do you mean these?

set nocompatible
set runtimepath^=~/path/to/vimtex
set runtimepath+=~/path/to/vimtex/after
filetype plugin indent on
syntax enable

silent edit test.tex
\documentclass{minimal}
\begin{document}

Hello World!

\end{document}

Can you also provide the steps you use to reproduce? Preferably in full detail.

Finally, after you do \ll to start compilation and you see the "compiler started" notification, can you do this: type \lo to open the compiler output buffer. Copy the contents into your reply.

@roao
Copy link
Author

roao commented May 8, 2022

Thank you for your reply!
Yes, I mean I test the bug using these:

set nocompatible
let &runtimepath  = '~\AppData\Local\nvim-data\site\pack\packer\opt\vimtex,' . &runtimepath
let &runtimepath .= '~\AppData\Local\nvim-data\site\pack\packer\opt\vimtex\after,' . &runtimepath
filetype plugin indent on
syntax enable

and

\documentclass{minimal}
\begin{document}
Hello world!
\end{document}

I begin the test in windows powershell using nvim -u .\minimal.vim .\minimal.tex. After \ll, I can open the pdf file in SumatraPDF(v3.3.3 64-bit) by typing \lv.
The compiler output buff shows:

Rc files read:
  NONE
Latexmk: This is Latexmk, John Collins, 21 September 2021, version: 4.75.
======= Need to update make_preview_continuous for target files
Not using a previewer
------------
Running 'echo vimtex_compiler_callback_compiling'
------------
vimtex_compiler_callback_compiling
Rule 'pdflatex': File changes, etc:
   Changed files, or newly in use since previous run(s):
      'minimal.tex'
------------
Run number 1 of rule 'pdflatex'
------------
Latexmk: applying rule 'pdflatex'...
------------
Running 'pdflatex  -file-line-error -synctex=1 -interaction=nonstopmode -recorder  "minimal.tex"'
------------
This is pdfTeX, Version 3.141592653-2.6-1.40.23 (TeX Live 2021/W32TeX) (preloaded format=pdflatex)
 restricted \write18 enabled.
entering extended mode
(./minimal.tex

LaTeX2e <2021-06-01> patch level 1
L3 programming layer <2021-10-18>
 (c:/Software/TeXLive/2021/texmf-dist/tex/latex/base/minimal.cls

Document Class: minimal 2001/05/25 Standard LaTeX minimal class
)
 (c:/Software/TeXLive/2021/texmf-dist/tex/latex/l3backend/l3backend-pdftex.def
)
 (./minimal.aux)
 [1
{c:/Software/TeXLive/2021/texmf-var/fonts/map/pdftex/updmap/pdftex.map
}
]
 (./minimal.aux)
 )<c:/Software/TeXLive/2021/texmf-dist/fonts/type1/public/amsfonts/cm/cmr10.pfb
>

Output written on minimal.pdf (1 page, 12600 bytes).
SyncTeX written on minimal.synctex.gz.

Transcript written on minimal.log.
Latexmk: Log file says output to 'minimal.pdf'
Rule 'pdflatex': File changes, etc:
   Changed files, or newly in use since previous run(s):
      'minimal.aux'
------------
Run number 2 of rule 'pdflatex'
------------
Latexmk: Examining 'minimal.log'
=== TeX engine is 'pdfTeX'
Latexmk: applying rule 'pdflatex'...
------------
Running 'pdflatex  -file-line-error -synctex=1 -interaction=nonstopmode -recorder  "minimal.tex"'
------------
This is pdfTeX, Version 3.141592653-2.6-1.40.23 (TeX Live 2021/W32TeX) (preloaded format=pdflatex)
 restricted \write18 enabled.
entering extended mode
(./minimal.tex

LaTeX2e <2021-06-01> patch level 1
L3 programming layer <2021-10-18>
 (c:/Software/TeXLive/2021/texmf-dist/tex/latex/base/minimal.cls

Document Class: minimal 2001/05/25 Standard LaTeX minimal class
)
 (c:/Software/TeXLive/2021/texmf-dist/tex/latex/l3backend/l3backend-pdftex.def
)
 (./minimal.aux
)
 [1
{c:/Software/TeXLive/2021/texmf-var/fonts/map/pdftex/updmap/pdftex.map
}
]
 (./minimal.aux)
 )<c:/Software/TeXLive/2021/texmf-dist/fonts/type1/public/amsfonts/cm/cmr10.pfb
>

Output written on minimal.pdf (1 page, 12600 bytes).
SyncTeX written on minimal.synctex.gz.

Transcript written on minimal.log.
Latexmk: Log file says output to 'minimal.pdf'
Latexmk: Examining 'minimal.log'
=== TeX engine is 'pdfTeX'
Latexmk: All targets (minimal.pdf) are up-to-date
------------
Running 'echo vimtex_compiler_callback_success'
------------
vimtex_compiler_callback_success

and more, the output of typing :VimtexLog is

19:05:32: info
  #0 C:\Users\61F\AppData\Local\nvim-data\site\pack\packer\opt\vimtex\autoload\vimtex\compiler.vim:206
  In vimtex#compiler#start
    call vimtex#log#info('Compiler started in continuous mode')
  #1 C:\Users\61F\AppData\Local\nvim-data\site\pack\packer\opt\vimtex\autoload\vimtex\compiler.vim:107
  In vimtex#compiler#compile
    call vimtex#compiler#start()
  Compiler started in continuous mode

@lervag
Copy link
Owner

lervag commented May 8, 2022

That's strange. Everything looks right...

Can you repeat the test, but now with nvim --clean -u minimal.vim minimal.tex? The --clean is necessary to avoid any other custom configuration you may have.

@roao
Copy link
Author

roao commented May 8, 2022

I have tried several commits, and callback fails since the commits on Apr 6, 2022, maybe the strict match to check callback type works wrong for encoding problem?

@roao
Copy link
Author

roao commented May 8, 2022

oh, I forgot the link to the commit: b32c470

@lervag
Copy link
Owner

lervag commented May 8, 2022

Did you test with the --clean option?

@lervag
Copy link
Owner

lervag commented May 8, 2022

But OK, I see that you may be right that the specified commit affects this. Although it is still surprising. Perhaps it has to do with Windows vs unix stuff.

Can you do some debugging in your end? I.e., first change the following code in your local vimtex repo:

function! s:check_callback(line) abort " {{{1
if a:line ==# 'vimtex_compiler_callback_compiling'
call vimtex#compiler#callback(1)
elseif a:line ==# 'vimtex_compiler_callback_success'
call vimtex#compiler#callback(2)
elseif a:line ==# 'vimtex_compiler_callback_failure'
call vimtex#compiler#callback(3)
endif
endfunction
" }}}1

to this:

function! s:check_callback(line) abort " {{{1
  if a:line =~# 'vimtex_compiler'
    echom 'DBG: |' . a:line . '|'
  endif

  if a:line ==# 'vimtex_compiler_callback_compiling'
    call vimtex#compiler#callback(1)
  elseif a:line ==# 'vimtex_compiler_callback_success'
    call vimtex#compiler#callback(2)
  elseif a:line ==# 'vimtex_compiler_callback_failure'
    call vimtex#compiler#callback(3)
  endif
endfunction

" }}}1

The point is to inspect the input to the check_callback function. Now, with the above change, repeat the minimal example steps. It should now give some extra output. You may not fully see it, so you can use :messages to see the messages. Copy the output here. I expect to see lines like this:

DBG: |Running 'echo vimtex_compiler_callback_success'|
DBG: |vimtex_compiler_callback_success|

Although the latter should not appear like that (because then things would work as expected).

@roao
Copy link
Author

roao commented May 9, 2022

Ok, the option: --clean could not change the resualt, callback still failed.
I have tried debugging and it gave me the output:

DBG: |vimtex_compiler_callback_compiling^M|
DBG: |vimtex_compiler_callback_success^M|

which may use encoding: gbk? I have set my windows language setting to use utf-8 in non-Unicode program, maybe it is not enough.

@lervag
Copy link
Owner

lervag commented May 9, 2022

Ah, yes, there it is. Thanks! I'll try to fix immediately.

@lervag
Copy link
Owner

lervag commented May 9, 2022

Sorry, I forgot to explain: the problem is related to :help file-formats. Notice how the end-of-line characters differ between OSs.

lervag added a commit that referenced this issue May 9, 2022
@lervag
Copy link
Owner

lervag commented May 9, 2022

I believe this should be resolved now. Please test.

@lervag lervag closed this as completed May 9, 2022
@roao
Copy link
Author

roao commented May 10, 2022

Sorry, but it still fails on my computer, I have updated the plugin, and tested it by using nvim --clean -u minimal.vim minimal.tex. I tried add echom in vimtex:

function! s:check_callback(line) abort " {{{1
  let l:status = get(s:callbacks, substitute(a:line, "\n$", '', ''))

  if a:line =~# 'vimtex_compiler'
    echom 'DBG: |' . a:line . '|'
    echom 'DBG: |' . substitute(a:line, "\n$", '', '') . '|'
    echom 'DBG: |' . l:status . '|'
  endif

  if l:status <= 0 | return | endif

  call vimtex#compiler#callback(l:status)
endfunction

let s:callbacks = {
      \ 'vimtex_compiler_callback_compiling': 1,
      \ 'vimtex_compiler_callback_success': 2,
      \ 'vimtex_compiler_callback_failure': 3,
      \}

" }}}1

It gave me the output:

DBG: |vimtex_compiler_callback_compiling^M|
DBG: |vimtex_compiler_callback_compiling^M|
DBG: |0|
DBG: |vimtex_compiler_callback_success^M|
DBG: |vimtex_compiler_callback_success^M|
DBG: |0|

^M still exists in the end of lines :(

lervag added a commit that referenced this issue May 10, 2022
@lervag
Copy link
Owner

lervag commented May 10, 2022

Sorry, the regex was off. Try now.

@roao
Copy link
Author

roao commented May 11, 2022

Ok, it works perfectly now, thank you!

@lervag
Copy link
Owner

lervag commented May 11, 2022

Glad to hear it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants