Shougo / neocomplcache.vim

Ultimate auto-completion system for Vim.
http://www.vim.org/scripts/script.php?script_id=2620
1.72k stars 135 forks source link

is there a way to load dictionary files at startup ? #445

Closed benintech closed 11 years ago

benintech commented 11 years ago

Hi, I'm using 2 dictionary files, english and french, together they weigh about 3 Mbytes. I increased g:neocomplcache_caching_limit_file_size to 10.000.000 to be sure it can hold both dictionaries in cache memory

Everything works fine, except when I start Vim : I type my 3 characters (my g:neocomplcache_auto_completion_start_length is set to 3), and then it freezes for 6 or 7 seconds, until finally the keyword list shows up.

Except for that first time, the keyword list is really fast to show up, and neocomplcache works just fine.

My question: is there a way to automatically load the dictionary files at vim startup ? I mean, usually after having started Vim I spend a few seconds to "hop around" in my file, doing some reading, going to the desired line, ... So it would be great to use these few seconds to load the dictionary files, so when I start typing they're already loaded.

I tried to type :NeoComplCacheCachingDictionary just after vim startup, but no luck (I get E121: Undefined variable: g:neocomplcache_dictionary_patterns)

Is there a way to load all dictionary files into cache right after vim startup ?

Thanks Ben

Shougo commented 11 years ago

I tried to type :NeoComplCacheCachingDictionary just after vim startup, but no luck (I get E121: Undefined variable: g:neocomplcache_dictionary_patterns)

You must execute call neocomplcache#initialize() before it.

benintech commented 11 years ago

Ok so after Vim starts up, I type: :call neocomplcache#initialize() :NeoComplCacheCachingDictionary

Indeed I don't have the "undefined variable" error anymore, but my dictionary files still don't seem to be loaded at startup. The first time the keyword list shows up still takes about 6 seconds. Is there anything else to do ?

Thanks for your help, Ben

Shougo commented 11 years ago

Indeed I don't have the "undefined variable" error anymore, but my dictionary files still don't seem to be loaded at startup.

To cache dictionary, you must set filetype same to dictionary filetype.

The first time the keyword list shows up still takes about 6 seconds. Is there anything else to do ?

You should install vimproc.

https://github.com/Shougo/vimproc.vim

benintech commented 11 years ago

To cache dictionary, you must set filetype same to dictionary filetype.

I don't quite understand, what exactly should I type ? I'd like my dictionary files to be loaded regardless of what filetype I'm working on Below my settings:

filetype plugin on
let g:neocomplcache_enable_at_startup = 1
let g:neocomplcache_dictionary_filetype_lists = {'_' : '/usr/share/dict/french,/usr/share/dict/american-english'} 
let g:neocomplcache_caching_limit_file_size = 10000000
let g:neocomplcache_auto_completion_start_length = 3
let g:neocomplcache_min_keyword_length = 6
let g:neocomplcache_enable_auto_select = 1 

Then after vim starts up, I type :call neocomplcache#initialize() :NeoComplCacheCachingDictionary Is there something I did wrong ? (I also tried :NeoComplCacheCachingDictionary _)

As for vimproc, I installed it just after neocomplcache (I suppose I installed it correctly because now "echo g:neocomplcache_use_vimproc" gives me1). Although, I didn't notice any difference between with and without vimproc (but then again, I don't complain about the speed, I think the keyword list is pretty swift to pop up, EXCEPT for that first time I type something)

Shougo commented 11 years ago

I don't know why your :NeoComplCacheCachingDictionary is not work. Sorry, I can't fix.

Shougo commented 11 years ago

You should put call neocomplcache#initialize() and NeoComplCacheCachingDictionary in your .vimrc.

Shougo commented 11 years ago

You may use neocomplete.vim instead of neocomplcache. It is faster.

https://github.com/Shougo/neocomplete.vim

I'm using 2 dictionary files, english and french, together they weigh about 3 Mbytes.

I think your dictionary file is too big. Vim script is slow. You should not use big dictionary.

dusans commented 11 years ago

I switched to neocomplete yesterday and on my large files (python, yaml) its noticeable faster. Thanks Shougo! :+1: