davidhalter / jedi-vim

Using the jedi autocompletion library for VIM.
MIT License
5.27k stars 370 forks source link

Cache does not seem to be caching. Slow autocomplete. #1116

Closed ClayShoaf closed 10 months ago

ClayShoaf commented 10 months ago

Issue

When I try to do a . autocomplete, it takes a long time to load the options. I have looked at some other issues, like https://github.com/davidhalter/jedi-vim/issues/163, but I have not installed any other plugins. Please see the section called "ATTENTION" as it looks like there is probably a simple solution, but I am not sure exactly what I need to add/edit in my init.vim file.

If you are not using jedi-vim from Git (but e.g. from a distribution's package, please try it with jedi-vim's Git master, too).

I assume that's what Vundle is doing when I include the line Plugin 'davidhalter/jedi-vim' in my init.vim file, but if not, please let me know and I will see if I can install it some other way.

jedi-vim slow.webm

Steps to reproduce

You can use the following template (save it as minimal.vimrc in the directory where jedi-vim is installed, cd into that directory, and run Vim with vim -u minimal.vimrc):

set nocompatible

let script_dir = fnamemodify(expand('<sfile>'), ':h')
let &runtimepath .= ','.script_dir.','.script_dir.'/after'

" Put your config changes here.
" let g:jedi#show_call_signatures=1

syntax on
filetype plugin indent on

ATTENTION

I just tried that and it significantly increased the speed on the second autocomplete! It's not the 50 ms that someone else reported, but it does go much faster, which is good.

Any idea what I should add from this to my init.vim? This is all that's in mine right now:

set nocompatible              " be iMproved, required
filetype off                  " required

set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'davidhalter/jedi-vim'
call vundle#end()            " required
filetype plugin indent on    " required

set scrolloff=10

augroup AutoView
  autocmd!
  autocmd BufWinLeave * silent! mkview
  autocmd BufWinEnter * silent! loadview
augroup END

***

Output of “:verbose JediDebugInfo”

Jedi-vim debug information

jedi-vim version
Global Python

Using Python version 3 to access Jedi.

Jedi
Jedi environment: <SameEnvironment: 3.10.12 in /usr>
Known environments
Settings
  omnifunc=jedi#completions
    Last set from ~/.vim/bundle/jedi-vim/autoload/jedi.vim line 723
  completeopt=menuone,longest,preview
    Last set from ~/.vim/bundle/jedi-vim/plugin/jedi.vim line 40

:version


NVIM v0.6.1
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by team+vim@tracker.debian.org

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/share/nvim"

Run :checkhealth for more info

:messages

:scriptnames ``` 1: ~/.config/nvim/init.vim 2: /usr/share/nvim/runtime/ftoff.vim 3: ~/.vim/bundle/Vundle.vim/autoload/vundle.vim 4: ~/.vim/bundle/Vundle.vim/autoload/vundle/config.vim 5: /usr/share/nvim/runtime/filetype.vim 6: /usr/share/nvim/runtime/ftplugin.vim 7: /usr/share/nvim/runtime/indent.vim 8: /usr/share/nvim/runtime/syntax/syntax.vim 9: /usr/share/nvim/runtime/syntax/synload.vim 10: ~/.vim/bundle/jedi-vim/plugin/jedi.vim 11: /usr/share/nvim/runtime/plugin/gzip.vim 12: /usr/share/nvim/runtime/plugin/health.vim 13: /usr/share/nvim/runtime/plugin/man.vim 14: /usr/share/nvim/runtime/plugin/matchit.vim 15: /usr/share/nvim/runtime/pack/dist/opt/matchit/plugin/matchit.vim 16: /usr/share/nvim/runtime/plugin/matchparen.vim 17: /usr/share/nvim/runtime/plugin/netrwPlugin.vim 18: /usr/share/nvim/runtime/plugin/rplugin.vim 19: /usr/share/nvim/runtime/plugin/shada.vim 20: /usr/share/nvim/runtime/plugin/spellfile.vim 21: /usr/share/nvim/runtime/plugin/tarPlugin.vim 22: /usr/share/nvim/runtime/plugin/tohtml.vim 23: /usr/share/nvim/runtime/plugin/tutor.vim 24: /usr/share/nvim/runtime/plugin/zipPlugin.vim 25: ~/.vim/bundle/jedi-vim/ftplugin/python/jedi.vim 26: ~/.vim/bundle/jedi-vim/autoload/jedi.vim 27: /usr/share/nvim/runtime/autoload/provider/python3.vim 28: /usr/share/nvim/runtime/autoload/provider/pythonx.vim 29: /usr/share/nvim/runtime/autoload/remote/host.vim 30: /usr/share/nvim/runtime/autoload/provider.vim 31: /usr/share/nvim/runtime/ftplugin/python.vim 32: ~/.vim/bundle/jedi-vim/after/ftplugin/python/jedi.vim 33: /usr/share/nvim/runtime/indent/python.vim 34: /usr/share/nvim/runtime/syntax/python.vim 35: ~/.vim/bundle/jedi-vim/after/syntax/python.vim 36: ~/.local/share/nvim/view/~=+programming=+python=+matplotlib=+animation.py= 37: /usr/share/nvim/runtime/autoload/provider/clipboard.vim ```
davidhalter commented 10 months ago

Thanks for the report, but this is unfortunately a known issue of https://github.com/davidhalter/jedi/issues/1059

There is not a lot we can do here for now, because this is really an architectural issue. I'm trying to fix it by rewriting Jedi in Rust, but that's still years away from completion. My type checker is probably at 50-60% (mypy clone) finished, but even that will take a long time and after that I will start with completions.

The issue you are seeing here is that some large libraries like matplotlib and numpy are just too big for Jedi's current design. I'm closing, because this is really the Jedi issue that I've linked.

ClayShoaf commented 10 months ago

@davidhalter I appreciate the reply!