Wednesday, June 29, 2011

Re: completion and caching

On Tue, 28 Jun 2011, Edward Peschko wrote:

> All,
>
> I'm attempting to use vim's omni-complete feature (ctrl-N, ctrl-P),
> and am finding - oddly enough - that it keeps on re-scanning the files
> in order to get the correct symbols, rather than doing what I would
> think would be the intelligent thing, namely caching the symbols it
> does find, and then updating that cache dynamically as I type.
>
> Is it possible to set it up so such a cache exists? I could see two
> levels of cache - one, a universal cache, and two, a local cache that
> is specific to the vim executable and populated each time the complete
> function is invoked.

The (non?-)problem is that Vim's omnicompletion API only
specifies that an omnicompletion function should be of the form:

function functionname(findstart, base)

The first time it's called as functionname(1, ''). That means the
function should find the start of the current 'word' to be
omnicompleted.

The second time it's called as functionname(0, 'start of word'). Then
the function should actually perform omnicompletion.

So, virtually all of the implementation is left to the function itself.
(Details at: :help complete-functions ).

The reason I say that it's a non-problem (with uncertainty) is that the
tradeoff is a huge amount of flexibility. You've run into one reason
this flexibility is problematic: things like caching are left up to the
omnifunction implementations themselves.

PHP's omnicompletion does a decent job of caching, IMO. Whereas under
Perl, I constantly see the flashes of "Scanning included file: ...".

The reason caching is complicated is that, while changing a file, you
change the set of included files. And included files can change outside
of Vim. And the set of included files is recursive. All of these
things are language-dependent, making the implementation of a central
"Just let Vim itself handle caching" solution problematic under the
current, very-flexible framework.

--
Best,
Ben

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments:

Post a Comment