Trigger completion popup after 2 letters in a word.

Everything about the completion popup currently works as it did before.
Update the text view while completion popup is up.

Before we only highlighted your typing as you went in the completion
popup, now the text also properly appears in the text view.
Try to leave the caret at the end after completion popup closes.

We're not all the way there, but most of the time the caret ends up at
either where it should be if the completions are ultimately ignored, or
it ends up at the end of the completed text when the completion is
accepted.
Insert completions as text, not snippets.

Inserting as snippets was having some very bizarre side-effects at times
when space was being hit. More to come on that front, I think. However,
it didn't seem like snippet insertion was being used anywhere at the
moment anyway, as in no snippets were ever suggested.
Restore snippet handling in completion, drop space as accept.

The real culprit was that space accepted the completion
instead of ignoring it, which doesn't make sense as you
type. For now, removing space as an accept action.
Add autocomplete option in preference pane + default to YES.

We're going to try a proper implementation of complete as
you type, which will involve slightly differing behaviors for
the completion popup depending on which mode it's invoked
in, so we need this preference in place.
Apply completion aggressiveness flag everywhere.

We missed a spot, so depending on the path you took the
completion controller could still aggressively choose to
close the window based on only having 1 completion, even
if completion was initiated in a non-aggressive way.
Pass keys from completion controller to text view as well.

We pass in the text view's key manager when initializing
the completion controller, and it goes on to pass keystrokes
back to the text view. This way, we're updating the contents
of the text view as the user types, in addition to filtering the
completion view itself.

This replaces the old
completionController:appendedStringWithoutCompleting:
hack, which was totally broken anyway.
Trigger completion window based on autocomplete preference.

We also only trigger it once at a time. So if the completion
window is already up, we don't try to bring it back up, which
will reset its state. Instead, we track if we've currently got
a window up (which is easy since it runs modally) and don't
try again until it's gone.
Move check for whether completion window is up.

We now check in the central presentCompletionsOf: method
instead of checking only when checking the autocomplete
trigger, since we've changed how completions work in
general. We also update the flag in presentCompletionsOf:
as well.
Make space accept only if not autocompleting.

We add a selector, accept_if_not_autocompleting:, to
the completion controller. When invoked via autocomplete,
the completion controller gets a C option, which we check
for and then set on an instance variable. That variable is
then checked when invoking accept_if_not_autocompleting:
to see if the selected entry should be accepted or not.

The effect of this is that invoking autocomplete via C-N will
accept on space, since you explicitly asked for the
completion popup, while if it pops up via autocomplete it will
only accept on enter/tab. The additional effect is that this is
customizable behavior -- the relevant keys can simply be
remapped to accept: or accept_if_not_autocompleting:
as desired.
Properly set the completion range after it's selected.

Now that we're filling in keys to the text view as they're
being procesed by the completion controller as well, we
need the range to reflect the fact that all prefix/filter text in
the completion controller needs to be replaced with
whatever completion was selected.
Replace complex NSInvocation with a regular message send.
Strip handling of terminating key in ViTextView.

Because all keys are sent to the text view anyway, there's
no reason at all to handle the terminating key after the
completion popup goes away, as it's already been handled.
Don't autocomplete in command line for now.

For now, we would end up with bad completions anyway
because we always use a ViWordCompletion when
autocompleting.
Set the range properly when completing aggressively.

When we complete aggressively, we go through a separate
return flow if there is only one completion available. We
weren't setting up the range properly for that situation.
Properly update _prefixLength/_range for partial completion.

Partial completion fills in a common prefix of multiple
completions. It's typically triggered by the tab key. We had
changed how we computed the range in those situations,
and stopped updating prefixLength properly. This broke
range computations and therefore insertion in these cases.
Merge remote-tracking branch 'origin/master' into completion-as-you-type
Merge branch 'master' into completion-as-you-type
Pass delegate to chooseFrom: in ViCompletionController.

Before it was expected that the delegate would be set
before, but then ViCompletionController runs a reset when
it starts. This way we ensure that the completion controller
has the proper delegate while it's modally presented, and all
exit points reset the controller and clear out the delegate
by consequence, making this a safer flow.