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

Really a large lag if insert after a brace '{' #2292

Closed
RnYi opened this issue Jan 6, 2022 · 16 comments
Closed

Really a large lag if insert after a brace '{' #2292

RnYi opened this issue Jan 6, 2022 · 16 comments
Labels

Comments

@RnYi
Copy link

RnYi commented Jan 6, 2022

Description

As the title said, inputing something after '{' will get a large lag. I test on both gvim(with coc.nvim) and neovim (with coc.nvim and nvim-cmp). I have a profile log to show you the problem:

FUNCTIONS SORTED ON TOTAL TIME
count  total (s)   self (s)  function
   30   4.249953   0.001727  coc#api#call()
   16   4.241497   0.000218  213()
    6   4.240878   0.003201  vimtex#complete#omnifunc()
    3   4.237677   0.000034  176()
    3   4.237643   0.000061  177()
    3   4.237582   0.004454  <SNR>87_get_texmf_candidates()
    6   4.233127   0.000816  vimtex#kpsewhich#run()
    6   4.220623   0.003417  vimtex#jobs#capture()
    6   4.214402   0.000117  vimtex#jobs#vim#capture()
    6   4.214286   0.007702  <SNR>128_vim_win_capture()
    1   0.028680   0.000021  <SNR>29_SyncAutocmd()
    1   0.028658   0.000027  coc#rpc#request()
    1   0.028619   0.028517  <SNR>32_request()
    8   0.015526   0.000466  193()
    8   0.008081   0.000194  vimtex#delim#get_current()
    8   0.007887   0.007030  <SNR>89_get_delim()
   12   0.007655             vimtex#paths#pushd()
   28   0.007067   0.004796  lightline#link()
    9   0.006729   0.003608  216()
   36   0.005851   0.000697  <SNR>29_Autocmd()

FUNCTIONS SORTED ON SELF TIME
count  total (s)   self (s)  function
    1   0.028619   0.028517  <SNR>32_request()
    6   4.214286   0.007702  <SNR>128_vim_win_capture()
   12              0.007655  vimtex#paths#pushd()
    8   0.007887   0.007030  <SNR>89_get_delim()
   28   0.007067   0.004796  lightline#link()
    3   4.237582   0.004454  <SNR>87_get_texmf_candidates()
   12              0.004277  vimtex#paths#popd()
    8              0.003722  192()
    9   0.006729   0.003608  216()
   36   0.003717   0.003478  <SNR>32_notify()
    6   4.220623   0.003417  vimtex#jobs#capture()
    6   4.240878   0.003201  vimtex#complete#omnifunc()
    3   0.002968   0.002896  coc#util#get_complete_option()
    8              0.002750  vimtex#syntax#stack()
   12   0.002704   0.002574  <SNR>37_Highlight_Matching_Pair()
    1   0.002271   0.002199  lightline#highlight()
   30   4.249953   0.001727  coc#api#call()
    2   0.001819   0.001575  <SNR>25_xkb_switch()
    1              0.001125  coc#util#echo_messages()
    6   0.001318   0.001018  lightline#onetab()

Steps to reproduce

No response

Expected behavior

No response

Actual behavior

No response

Do you use a latexmkrc file?

No

VimtexInfo

System info:
  OS: RANY-PC (Microsoft Windows 10 רҵ°æ)
  Vim version: VIM 8.2 (1-3491)
  Has clientserver: true
  Servername: GVIM

VimTeX project: test
  base: test.tex
  root: C:\Users\RanY\Desktop\OtherProjects\MyTheses\GraduationThesis
  tex: C:\Users\RanY\Desktop\OtherProjects\MyTheses\GraduationThesis\test.tex
  main parser: current file
  document class: 
  packages: article
  compiler: latexmk
    engine: -xelatex
    options:
      -verbose
      -file-line-error
      -synctex=1
      -interaction=nonstopmode
    build_dir: .tmp
    callback: 1
    continuous: 1
    executable: latexmk
  viewer: General
  qf method: LaTeX logfile
@RnYi RnYi added the bug label Jan 6, 2022
@RnYi
Copy link
Author

RnYi commented Jan 6, 2022

I also test on vim with a minimal.vim as your example, so I have to use <C-x><C-o> to invoke complete menu, and errors are reported when I press after '{':
image

here is a translation of above errors:

Error detected while processing function vimtex#complete#omnifunc[30]..169[1]..170[2]..<SNR>61_get_texmf_candidates:
Line 16:
E484: Can not open file c:/texlive/texmf-local/ls-R^M
Error detected while processing function vimtex#complete#omnifunc[30]..169[1]..170:
Line 2:
E896: Argument of map() must be a List, Dictionary or Blob
Error detected while processing function vimtex#complete#omnifunc[30]..169[1]..<SNR>61_filter:
Line 16:
......

@lervag
Copy link
Owner

lervag commented Jan 8, 2022

I'm quite sure this is related to things described in #2291.

Can you do this:

  1. Create some empty test folder.
  2. Create file test.vim with the content below.
  3. Run nvim --clean --headless -u test.vim from inside the folder (e.g. from Powershell).
" test.vim
set nocompatible
set runtimepath^=/path/to/vimtex
filetype plugin indent on

let g:vimtex_cache_root = '.'

silent edit empty.tex

for s:x in vimtex#kpsewhich#run('--all ls-R')
  unsilent echo printf("file: '%s'", s:x)
endfor

quitall!

@RnYi
Copy link
Author

RnYi commented Jan 8, 2022

I'm quite sure this is related to things described in #2291.

Can you do this:

  1. Create some empty test folder.
  2. Create file test.vim with the content below.
  3. Run nvim --clean --headless -u test.vim from inside the folder (e.g. from Powershell).
" test.vim
set nocompatible
set runtimepath^=/path/to/vimtex
filetype plugin indent on

let g:vimtex_cache_root = '.'

silent edit empty.tex

for s:x in vimtex#kpsewhich#run('--all ls-R')
  unsilent echo printf("file: '%s'", s:x)
endfor

quitall!

I put the test.vim in a empty dir, and output are below:

'ile: 'c:/texlive/texmf-local/ls-R
'ile: 'c:/texlive/2021/texmf-config/ls-R
'ile: 'c:/texlive/2021/texmf-var/ls-R
'ile: 'c:/texlive/2021/texmf-dist/ls-R

nvim_servernames.log is generated in the dir, with content below:

\\.\pipe\nvim-10508-0

@lervag
Copy link
Owner

lervag commented Jan 8, 2022

Thanks. The output is not as expected, which is "good" in the sense that this may explain the issue. On my end, the output is similar to "file: '/path/ls-R'" on each line.

If you do nvim test.tex, then do :echo systemlist('cmd /s /c "kpsewhich --all ls-R"') - what's the output now?

@lervag
Copy link
Owner

lervag commented Jan 8, 2022

Oh, and the nvim_servernames.log is not important here, so just disregard it.

lervag added a commit that referenced this issue Jan 8, 2022
@lervag
Copy link
Owner

lervag commented Jan 8, 2022

I hope this may be fixed now. Can you update, then do :VimtexClearCaches all. Then first repeat my above minimal test and report the output, then try to reproduce the original issue.

@RnYi
Copy link
Author

RnYi commented Jan 8, 2022

I hope this may be fixed now. Can you update, then do :VimtexClearCaches all. Then first repeat my above minimal test and report the output, then try to reproduce the original issue.

output:

file: 'c:/texlive/texmf-local/ls-R'
file: 'c:/texlive/2021/texmf-config/ls-R'
file: 'c:/texlive/2021/texmf-var/ls-R'
file: 'c:/texlive/2021/texmf-dist/ls-R'

Now all packages installed locally can be suggested by omni. Although the large lag still exists, it only appeared in the beginning I input something after '\documentclass{' and \usepackage{, It seems like VimTex is loading packages in such a lag.

@lervag
Copy link
Owner

lervag commented Jan 8, 2022

I don't experience the lag myself (at all!), so I would not mind figuring out what the problem is. Are you able to create a minimal example and explain the details of reproducing?

Also, an updated profiling would be nice (please explain how you do it, though - it helps me to properly understand what I see).

@RnYi
Copy link
Author

RnYi commented Jan 8, 2022

I don't experience the lag myself (at all!), so I would not mind figuring out what the problem is. Are you able to create a minimal example and explain the details of reproducing?

Also, an updated profiling would be nice (please explain how you do it, though - it helps me to properly understand what I see).

My minimal.vim:

set nocompatible
let &runtimepath  = '~/.vim/bundle/vimtex,' . &runtimepath
" let &runtimepath  = '~/.vim/bundle/coc.nvim,' . &runtimepath
let &runtimepath .= ',~/.vim/bundle/vimtex/after'
" let &runtimepath .= ',~/.vim/bundle/coc.nvim/after'
filetype plugin indent on
syntax enable
let g:vimtex_view_general_viewer = 'SumatraPDF.exe'

how to reproduce:

  1. nvim -u minimal.vim test.tex
  2. run cmd :profile start output.log and :profile func vimtex*, so that all functions whose name begin with 'vimtex' will be profiled.
  3. press <C-x><C-o> after "\documentclass{", completing menu will appear after a large lag. But next time you want to compelete documentclass, no lag bothers you. And also, a large lag will appear in the first time you compelete \usepackage and lag goes away in next time.

my output.log:
output.log

Maybe it's just a performance issue specific to Windows

@lervag
Copy link
Owner

lervag commented Jan 8, 2022

Could you show the profile log with profile func *? The filter removes the function that actually causes the lag.

@lervag
Copy link
Owner

lervag commented Jan 8, 2022

Hmm, ok, I can reproduce this. It is same with Vim and neovim in my test setup. The lag is caused by the call systemlist line in jobs/*.vim and is in a way not really due to VimTeX. This is used to run kpsewhich --all ls-R to find the available package files and similar for completion.

Not sure what to do about this, right now. The kpsewhich call is quick on Linux.

@lervag
Copy link
Owner

lervag commented Jan 8, 2022

My tests earlier were all with MikTeX. I now uninstalled MikTeX and installed TeXlive and now kpsewhich was suddenly much faster and everything worked as expected. Did you by any chance switch to MikTeX in the meantime?

@RnYi
Copy link
Author

RnYi commented Jan 9, 2022

My tests earlier were all with MikTeX. I now uninstalled MikTeX and installed TeXlive and now kpsewhich was suddenly much faster and everything worked as expected. Did you by any chance switch to MikTeX in the meantime?

No, I installed only texlive.

@lervag
Copy link
Owner

lervag commented Jan 9, 2022

Well, then, ok. I don't know what else to do here. Sorry. :\

Could you try to reinstall texlive? I used a more or less minimal install - perhaps thats the problem?

@RnYi
Copy link
Author

RnYi commented Jan 10, 2022

Well, then, ok. I don't know what else to do here. Sorry. :\

Could you try to reinstall texlive? I used a more or less minimal install - perhaps thats the problem?

Maybe. I installed almost all packages :). Thank you for your hard working, close it.

@RnYi RnYi closed this as completed Jan 10, 2022
@lervag
Copy link
Owner

lervag commented Jan 10, 2022

Thanks - feel free to open a similar/related issue if you're able to pinpoint more specifically how I could improve VimTeX. In the meantime, I hope it works well enough!

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