Commit Graph

2361 Commits

Author SHA1 Message Date
micbou
743f2e7b96
Fix pyenv setup on Travis
Travis complains that the /home/travis/.pyenv folder already exists. Remove it
before installing pyenv.
2017-09-05 20:39:22 +02:00
micbou
dda721ec07
Fix directory creation on Linux Travis
Travis complains that the /home/travis/bin folder already exists when creating
it. Use mkdir with the -p option.
2017-09-05 20:39:13 +02:00
micbou
f185b4ef12
Update ClearCompilationFlagCache docs 2017-09-05 14:17:39 +02:00
zzbot
65765ef32b Auto merge of #2752 - micbou:improve-server-logs-message, r=micbou
[READY] Improve error message when server crashes

This PR improves the error message displayed to the user when the server unexpectedly crashes by giving the exact command to type to open the server logfile.

We could go further by automatically opening the server logfile but this is too disruptive in my opinion.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/2752)
<!-- Reviewable:end -->
2017-08-24 11:51:08 -07:00
micbou
031edea89e
Improve error message when server crashes
Give the exact command that the user needs to type to open the server logfile
when the server unexpectedly crashes.
2017-08-18 18:15:20 +02:00
zzbot
9a76fd2e9a Auto merge of #2750 - micbou:no-stderr-read, r=Valloric
[READY] Do not read server standard error

When the ycmd server crashes, we read its standard error and log the result. Unfortunately, this blocks Vim if a sub-server is still running after the crash (e.g. JediHTTP). In that case, the only way to unblock Vim is to manually kill the sub-server.

We could fix the issue by writing some (non-trivial) code that reads ycmd `stderr` without blocking but instead we simply don't read it at all. The drawback is small: [ycmd immediately redirects its `stdout` and `stderr` to logfiles at startup](ff255aed4a/ycmd/__main__.py (L150-L153)). In other words, reading its `stderr` is only useful if ycmd crashed before the redirection. This is something that should never happen.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/2750)
<!-- Reviewable:end -->
2017-08-18 04:41:58 -07:00
micbou
bdac8ed43e
Do not read server stderr
Reading ycmd stderr blocks Vim if a subserver process is still up even if ycmd
is not running.
2017-08-17 20:16:54 +02:00
zzbot
369fdade93 Auto merge of #2737 - micbou:pin-ycm-extra-conf-docs, r=bstaletic
[READY] Pin YCM extra conf version in documentation

By linking to a specific version of [ycmd `.ycm_extra_conf.py` file](https://github.com/Valloric/ycmd/blob/master/cpp/ycm/.ycm_extra_conf.py) in the docs, users following the link won't copy a version of this file that's incompatible with the current version of YCM when that file is modified because of a change in our `.ycm_extra_conf.py` specs (like in PR https://github.com/Valloric/ycmd/pull/795), and ycmd submodule is not yet updated.

Also, link to the raw file instead of the github page.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/2737)
<!-- Reviewable:end -->
2017-08-01 14:25:40 -07:00
micbou
9f5b45cdc3
Pin YCM extra conf version in documentation 2017-08-01 18:34:56 +02:00
zzbot
51cb3859b8 Auto merge of #2736 - micbou:typo, r=puremourning
[READY] Fix typo in documentation

This ~~trigged~~ triggered me.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/2736)
<!-- Reviewable:end -->
2017-07-31 15:14:26 -07:00
micbou
904c23f7ce
Fix typo in documentation 2017-07-31 23:04:56 +02:00
zzbot
7ba7eefb19 Auto merge of #2733 - micbou:insert-keys-typeahead-start, r=bstaletic
[READY] Insert keys at the start of the typeahead buffer

When sending keys to Vim through `feedkeys`, these keys are by default added to the end of the typeahead buffer. If there are already keys in the buffer, they will be processed first and may change the state that our keys combination was sent for. For instance, `<C-X><C-U><C-P>` may be sent in normal mode instead of insert mode (issue #2731) or `<C-e>` outside of completion mode (issue #2732). We avoid that by inserting the keys at the start of the typeahead buffer with the `i` option.

Fixes #2731.
Fixes #2732.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/2733)
<!-- Reviewable:end -->
2017-07-31 05:37:53 -07:00
micbou
04f6497462
Insert keys at the start of the typeahead buffer
When sending keys to Vim, they are by default added to the end of the typeahead
buffer. If there are already keys in the buffer, they will be processed first
and may change the state that our keys combination was sent for (e.g.
<C-X><C-U><C-P> in normal mode instead of insert mode or <C-e> outside of
completion mode). We avoid that by inserting the keys at the start of the
typeahead buffer.
2017-07-31 10:58:40 +02:00
zzbot
998303e2fd Auto merge of #2728 - puremourning:vim-version-macOS, r=Valloric
[RFC] Add a more obvious explanation for users of the default system Vim on macOS

# PR Prelude

Thank you for working on YCM! :)

**Please complete these steps and check these boxes (by putting an `x` inside
the brackets) _before_ filing your PR:**

- [X] I have read and understood YCM's [CONTRIBUTING][cont] document.
- [X] I have read and understood YCM's [CODE_OF_CONDUCT][code] document.
- [X] I have included tests for the changes in my PR. If not, I have included a
  rationale for why I haven't.
- [X] **I understand my PR may be closed if it becomes obvious I didn't
  actually perform all of these steps.**

No tests because we don't have Vimscript tests. But I tested:

* System Vim on macOS:

```
BeniMac:YouCompleteMe-Clean ben$ /usr/bin/vi
YouCompleteMe unavailable: requires Vim 7.4.1578+.
Info: You appear to be running the default system Vim on macOS. It reports as patch 8056, but it is really older than 1578. Please consider MacVim, homebrew Vim or a self-built Vim that satisfies the minimum requirement.
Press ENTER or type command to continue
```

* Manually built too-old Vim on macOS (regression test)

```
BeniMac:vim ben$ ./src/vim
YouCompleteMe unavailable: requires Vim 7.4.1578+.
Press ENTER or type command to continue
BeniMac:vim ben$
```

* MacVim (latest) works
* Homebrew Vim (latest) works
* Whatever random Vim I was using before works

# Why this change is necessary and useful

As the comment says, and referred in [this issue]( https://github.com/Valloric/YouCompleteMe/issues/2721#issuecomment-317272969) and [this comment](https://github.com/Valloric/YouCompleteMe/issues/549#issuecomment-317272203) users of macOS are being flummoxed by the reporting of its version on the launch screen as some bogus patch number. I guess Apple patched it for some reason (such as their OS protection or something), and just chose a random high number (or perhaps some v8 back patch, who knows).

Anyway, a specific error message for such users means they can get a working system without reporting to us, but it's our overhead to maintain the extra code. So RFC for that reason.

[cont]: https://github.com/Valloric/YouCompleteMe/blob/master/CONTRIBUTING.md
[code]: https://github.com/Valloric/YouCompleteMe/blob/master/CODE_OF_CONDUCT.md

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/2728)
<!-- Reviewable:end -->
2017-07-24 00:24:05 -07:00
Ben Jackson
4f555a2c8d Add a more obvious explanation for users of the default system Vim on macOS 2017-07-23 22:17:24 +01:00
zzbot
f5b81bc17d Auto merge of #2722 - micbou:set-complete-func, r=Valloric
[READY] Check completefunc when forcing semantic completion

When `completefunc` is not set (because YCM is not allowed to complete in the current buffer or the server failed to start) and semantic completion is forced with `<C-Space>`, Vim returns the following error:
```
E764: Option 'completefunc' is not set
```
This happens because we don't check if `completefunc` is set to `youcompleteme#CompleteFunc` in that case.

To completely avoid this issue, we always set the `completefunc` before invoking it. This may look inefficient but, in practice, the performance cost is almost nil.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/2722)
<!-- Reviewable:end -->
2017-07-22 01:45:10 -07:00
zzbot
3e318800b4 Auto merge of #2723 - micbou:update-ycmd, r=puremourning
[READY] Update ycmd

This include the following changes:
 - PR https://github.com/Valloric/ycmd/pull/673: update bottle to 0.12.13;
 - PR https://github.com/Valloric/ycmd/pull/790: update Clang to 4.0.1;
 - PR https://github.com/Valloric/ycmd/pull/793: fix compilation with Clang 3.4;
 - PR https://github.com/Valloric/ycmd/pull/796: only configure tests and benchmarks if required;
 - PR https://github.com/Valloric/ycmd/pull/799: fix finding Python library in virtualenv;
 - PR https://github.com/Valloric/ycmd/pull/800: switch back to Boost regex.

Downgrade GCC requirement to 4.8 on Travis.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/2723)
<!-- Reviewable:end -->
2017-07-21 00:37:54 -07:00
micbou
342ba19730
Downgrade GCC requirement on Travis
GCC 4.8 is now enough to build ycmd.
2017-07-20 22:22:14 +02:00
micbou
bb03f0e056
Update ycmd
Include following changes:
 - update bottle to 0.12.13;
 - update Clang to 4.0.1;
 - fix compilation with Clang 3.4;
 - only configure tests and benchmarks if required;
 - fix finding Python library in virtualenv;
 - switch back to Boost regex.
2017-07-20 22:22:14 +02:00
micbou
5cd560c021
Check completefunc when forcing semantic completion
Vim returns an error when forcing semantic completion and the completefunc is
not set.
2017-07-20 21:52:08 +02:00
zzbot
1e38a2bfc5 Auto merge of #2710 - micbou:buffer-unload-unicode-warnings, r=vheon
[READY] Fix unicode warning when unloading buffer on Python 2

When a buffer is unloaded, [we compare its name to the current buffer one in the `BuildRequestData` function](5b89d41832/python/ycm/client/base_request.py (L160)). This raises a unicode warning on Python 2 when the deleted buffer name contains non-ASCII characters because the deleted buffer name is a byte object while the current buffer name is a unicode one.

I updated the `BufferUnload` test to show the issue. I'll send the fix once the builds failed.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/2710)
<!-- Reviewable:end -->
2017-07-08 08:51:33 -07:00
micbou
1e935db4b7
Fix unicode warning when unloading buffer on Python 2 2017-07-08 14:46:04 +02:00
micbou
2afc0d5f5f
Update BufferUnload test with Unicode paths 2017-07-08 14:19:27 +02:00
zzbot
5b89d41832 Auto merge of #2708 - micbou:omni-completer-omnifunc, r=vheon
[READY] Do not cache omnifunc on FileReadyToParse event

We currently cache the omnifunc when the file is ready to be parsed i.e. on the `FileType`, `BufEnter` events and possibly on `InsertLeave` and `TextChanged`. That's problematic if the omnifunc is modified after these events and the user is requesting completions from it. This was the cause of issue https://github.com/Valloric/YouCompleteMe/issues/1027 but is not relevant anymore because we now always parse the file on the `BufEnter` event and thus the omnifunc is properly updated after switching buffers. Still, it's more correct to cache the omnifunc inside the `ShouldUseNow` method since `ComputeCandidatesInner` is called immediately after. Performance is not a concern: it takes less than 10 μs to get the omnifunc.

Fixes https://github.com/Valloric/YouCompleteMe/issues/1027.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/2708)
<!-- Reviewable:end -->
2017-07-07 22:29:28 -07:00
micbou
139e3fbaf9
Add omnifunc tests 2017-07-07 22:45:05 +02:00
micbou
600383fbac
Do not cache omnifunc on FileReadyToParse event 2017-07-07 21:39:27 +02:00
zzbot
d299f9eb70 Auto merge of #2707 - micbou:fix-omnifunc-cursor-move, r=bstaletic
[READY] Restore cursor position after omnifunc call

When compiled without C-family support, YCM will use the default omnifunc from Vim (`ccomplete#Complete`) to provide semantic completion. This omnifunc calls [`searchdecl`](http://vimdoc.sourceforge.net/htmldoc/eval.html#searchdecl()) to find a declaration, which is supposed to move the cursor to that declaration. However, the cursor is not moved when called through the omni completion mapping (`CTRL-X CTRL-O`). Since PR https://github.com/Valloric/YouCompleteMe/pull/2657, YCM calls the omnifunc outside completion mode and thus the cursor is moved to the found declaration after typing `.` or `->`.

Considering this `searchdecl` trick may be used by other omnifuncs, we fix the issue by always restoring the cursor position after calling the omnifunc.

Fixes #2698.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/2707)
<!-- Reviewable:end -->
2017-07-07 06:29:34 -07:00
micbou
dec9c0f827
Add test with omnifunc moving cursor position 2017-07-07 13:59:57 +02:00
micbou
83bb78a2d6
Restore cursor position after omnifunc call
Calling directly the omnifunc may move the cursor position. This is the case
with the default Vim omnifunc for C-family languages (ccomplete#Complete) which
calls searchdecl to find a declaration. This function is supposed to move the
cursor to the found declaration but it doesn't when called through the omni
completion mapping (CTRL-X CTRL-O). So, we restore the cursor position after
calling the omnifunc.
2017-07-07 03:38:33 +02:00
zzbot
c9be11ab81 Auto merge of #2701 - micbou:rewrite-omnifunc-tests, r=Valloric
[READY] Rewrite omnifunc tests

Change the `VimBuffer` object to accept a Python function as its omnifunc, e.g.
```python
def Omnifunc( findstart, base ):
  if findstart:
    return 5
  return [ 'a', 'b', 'c' ]
```
and rewrite the omnifunc tests accordingly. This reduces the amount of mocking done directly in these tests.

Also, extend the `ToBytesOnPY2` function to lists and dictionaries so that, instead of having to write
```python
[ ToBytesOnPY2( 'a' ), ToBytesOnPY2( 'b' ), ToBytesOnPY2( 'c' ) ]
```
in tests, one can write:
```python
ToBytesOnPY2( [ 'a', 'b', 'c' ] )
```

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/2701)
<!-- Reviewable:end -->
2017-07-06 15:41:33 -07:00
micbou
db0b9ab335
Rewrite omnifunc tests
The VimBuffer object now accepts a Python function as its omnifunc.
2017-07-05 23:21:36 +02:00
zzbot
191b79ed65 Auto merge of #2702 - micbou:unicode-warnings, r=bstaletic
[READY] Fix unicode warning when jumping on Python 2

On Python 2, jumping in a file whose path contains non-ASCII characters raises the following warnings:
```
Error detected while processing function <SNR>26_CompleterCommand:
line   18:
python\ycm\vimsupport.py:400: UnicodeWarning: Unicode unequal comparison failed to convert both arguments to Unicode - interpreting them as being unequal
  if filename != GetCurrentBufferFilepath():
python\ycm\vimsupport.py:375: UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal
  if win.buffer.name == filepath:
```
This happens because, in the `JumpToLocation` function, we are comparing a unicode object (`filename` and `filepath`) with a Vim buffer name (`vim.current.buffer.name` returned by `GetCurrentBufferFilepath` and `win.buffer.name` where `win` is a Vim window) which is a byte object on Python 2.

For now, this PR adds tests covering the `JumpToLocation` function with unicode paths. They will raise the warnings on Python 2 and will fail because warnings are now treated as errors in tests. I'll update the PR with the fix once the builds are done.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/2702)
<!-- Reviewable:end -->
2017-07-05 13:29:12 -07:00
micbou
81546b901e
Fix HiddenEnabled function
The 'hidden' option is a global option, not a buffer one. If this option is
false, we should check if the 'bufhidden' option, which is local to the buffer,
is set to 'hide'. If so, the buffer can be hidden despite the 'hidden' option
being false.
2017-07-05 19:56:13 +02:00
zzbot
bd302907f5 Auto merge of #2704 - micbou:stop-polling-if-server-crashed, r=bstaletic
[READY] Stop polling for readiness if the server crashed

There is no need to continue polling the server if its process has terminated (i.e. the server crashed). This fixes issue https://github.com/Valloric/YouCompleteMe/issues/2683 when the server is not working.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/2704)
<!-- Reviewable:end -->
2017-07-05 01:28:17 -07:00
zzbot
bc6ff361af Auto merge of #2703 - micbou:stop-completion-polling-on-insert-leave, r=bstaletic
[READY] Stop completion polling when leaving insert mode

Completing outside insert mode is not going to work.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/2703)
<!-- Reviewable:end -->
2017-07-05 01:13:08 -07:00
micbou
1ceabea26e
Stop polling for readiness if server crashed 2017-07-05 05:19:47 +02:00
micbou
63bc2fb6e8
Stop completion polling on InsertLeave event 2017-07-05 04:46:05 +02:00
micbou
e573457563
Convert buffer name to unicode
Fix JumpToLocation tests on Python 2.
2017-07-05 02:25:30 +02:00
micbou
e5457affd8
Add JumpToLocation unicode tests 2017-07-05 00:55:29 +02:00
zzbot
9a1561e841 Auto merge of #2700 - micbou:check-if-server-is-ready-in-tests, r=bstaletic
[READY] Check if server is ready before running tests

We don't need to mock the `IsServerReady` function if we check that the server is ready before running each test.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/2700)
<!-- Reviewable:end -->
2017-07-03 15:54:32 -07:00
micbou
f31102e317
Check if server is ready before running tests 2017-07-03 18:06:01 +02:00
zzbot
25a2e3120c Auto merge of #2489 - puremourning:use-server-start-column, r=micbou
[READY] Reset the start column in omnifunc completer

# PR Prelude

Thank you for working on YCM! :)

**Please complete these steps and check these boxes (by putting an `x` inside
the brackets) _before_ filing your PR:**

- [X] I have read and understood YCM's [CONTRIBUTING][cont] document.
- [X] I have read and understood YCM's [CODE_OF_CONDUCT][code] document.
- [X] I have included tests for the changes in my PR. If not, I have included a
  rationale for why I haven't.
- [X] **I understand my PR may be closed if it becomes obvious I didn't
  actually perform all of these steps.**

# Why this change is necessary and useful

A number of issues have been raised over the years where YCM doesn't interact great with the user's omnifunc. This is commonly because we ignore the omnifunc's `findstart` response, and use our own implementation (`base.CompletionStartColumn`).

In combination with valloric/ycmd#681 this change uses the omnifunc's start column for completions and fixes valloric/ycmd#671 and others, such as:

- https://github.com/Valloric/YouCompleteMe/issues/1322 probably (not yet tested)
- https://github.com/Valloric/YouCompleteMe/issues/1957
- https://github.com/Valloric/YouCompleteMe/issues/1816

Note: This is just an initial test for sharing the code to gauge reaction. Not fully tested yet.

[cont]: https://github.com/Valloric/YouCompleteMe/blob/master/CONTRIBUTING.md
[code]: https://github.com/Valloric/YouCompleteMe/blob/master/CODE_OF_CONDUCT.md

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/2489)
<!-- Reviewable:end -->
2017-07-02 18:44:06 -07:00
Ben Jackson
5c98b69b6f Fix tests supplying findstart. It's 0-based. Known failure is no longer a known failure 2017-07-03 00:55:03 +01:00
Ben Jackson
e15c4927d1 Update ycmd submodule 2017-07-02 22:58:50 +01:00
Ben Jackson
c3984505db Use the omnifunc-supplied start column 2017-06-29 19:16:09 +01:00
zzbot
b564b5d8e3 Auto merge of #2697 - bstaletic:readme_fix, r=micbou
Correct vim 7.4 patch requirement

# PR Prelude

Thank you for working on YCM! :)

**Please complete these steps and check these boxes (by putting an `x` inside
the brackets) _before_ filing your PR:**

- [x] I have read and understood YCM's [CONTRIBUTING][cont] document.
- [x] I have read and understood YCM's [CODE_OF_CONDUCT][code] document.
- [ ] I have included tests for the changes in my PR. If not, I have included a
  rationale for why I haven't.
- [x] **I understand my PR may be closed if it becomes obvious I didn't
  actually perform all of these steps.**

# Why this change is necessary and useful

[Please explain **in detail** why the changes in this PR are needed.]

With Valloric/YouCompleteMe#2636 we bumped minimum required vim version to 7.4.1578, but in one place we didn't change the value.

Yes, this PR is just one number change, but inconsitency bothers me.

[cont]: https://github.com/Valloric/YouCompleteMe/blob/master/CONTRIBUTING.md
[code]: https://github.com/Valloric/YouCompleteMe/blob/master/CODE_OF_CONDUCT.md

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/2697)
<!-- Reviewable:end -->
2017-06-28 18:31:29 -07:00
Boris Staletic
8f68f1ca3e Correct vim 7.4 patch requirement 2017-06-28 08:06:20 +02:00
zzbot
6ba6b56fb7 Auto merge of #2657 - micbou:completion-system-rewrite, r=bstaletic
[READY] Rewrite completion system

There is a number of issues with the current completion system:
 - UI is blocked until the completions are returned by the server, the request timed out, or a key is pressed by the user. This leads to a rough experience when completions take too much time: cursor disappearing and timeout errors (see https://github.com/Valloric/YouCompleteMe/issues/2192 and https://github.com/Valloric/YouCompleteMe/issues/2574). Users even [increase the timeout by manually editing the `completion_request.py` file](https://github.com/Valloric/YouCompleteMe/blob/master/python/ycm/client/completion_request.py#L30) to avoid these errors, which exacerbate the issue and, in some cases, make the plugin unusable (see https://github.com/Valloric/YouCompleteMe/issues/2574).
 - no fuzzy matching from omnifunc when forcing semantic completion. See https://github.com/Valloric/YouCompleteMe/issues/961;
 - no fuzzy matching when deleting characters. Vim filtering is used instead:

![completion-bug-deleting-characters](https://cloud.githubusercontent.com/assets/10026824/26276156/f298c6de-3d71-11e7-92da-d22186239c27.gif)
Neovim and MacVim are not affected.
 - completion menu disappears after deleting a character and inserting one:

![completion-bug-reinserting-character](https://cloud.githubusercontent.com/assets/10026824/26276192/b3ed0f7a-3d72-11e7-8c64-523a0a59cbdc.gif)
Neovim and MacVim are not affected.
 - ignore the start column returned by the server. See PR https://github.com/Valloric/YouCompleteMe/pull/2489.
 - subject to flickers. This one depends a lot on the version of Vim. Completion is almost flicker-free in Neovim and MacVim. Not too bad in console Vim (except in fast terminal like [alacritty](https://github.com/jwilm/alacritty)). Awful in gVim GTK2 (a bit better on GTK3) and gVim on Windows.

This PR is an attempt at fixing all of these issues while reducing flickers as best as possible (due to how completion works in Vim, a flicker-free experience is impossible to achieve). Here's how:
 - poll for completions using a timer and call `completefunc` once the completions are ready. Use the start column returned by the server in `completefunc`;
 - immediately display the last completions on the `TextChangedI` event to prevent the popup menu disappearing while waiting for the completions. This reduces flickering;
 - use the `InsertCharPre` event to close the completion menu just before inserting a character. This way the `TextChangedI` event is triggered when the character is inserted (this event is not fired when the completion menu is visible). This replaces the `refresh` option set to `always` in `completefunc` and the `s:cursor_moved` hack;
 - remap the backspace key to close the completion menu when deleting a character and thus triggering the `TextChangedI` event;
 - send a request with `force_semantic` set to `True` when forcing semantic completion instead of calling the omnifunc. This fixes the issue where there is no fuzzy matching for custom omnifuncs.

Here's a demo where I added a spin animation on the command line while loading the completions to show that it doesn't block the Vim UI:

![async-completion-for-real](https://cloud.githubusercontent.com/assets/10026824/26277295/0f16a718-3d86-11e7-90f3-8a56bbf53f9f.gif)

Fixes #961.
Fixes #1282.
Fixes #1881.
Fixes #2192.
Fixes #2500.
Fixes #2574.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/2657)
<!-- Reviewable:end -->
2017-06-25 09:23:38 -07:00
micbou
377e472b7e
Add key mappings to close completion menu 2017-06-21 02:58:15 +02:00
micbou
223ae6ab9f
Rewrite completion system
Bring fully asynchronous completion by polling for completions with a timer
then calling completefunc once the completions are ready. Use the start column
returned by the server in completefunc. Immediately display the last completion
on the TextChangedI event to prevent the popup menu disappearing while waiting
for the completions. Handle the TextChangedI event not being triggered while
the completion menu is open by closing the menu when inserting a character
through the InsertCharPre event, and when deleting a character on the <BS> and
<C-h> keys.
2017-06-21 02:32:57 +02:00