Commit Graph

2213 Commits

Author SHA1 Message Date
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
zzbot
37d63e1aec Auto merge of #2691 - micbou:require-utf8-encoding, r=bstaletic
[READY] Require UTF-8 encoding

YCM expects the character encoding used by Vim to be UTF-8. If another encoding is used, inserting a non-ASCII character raises a `UnicodeDecodeError` exception resulting in a Python traceback inside Vim. However, supporting other encodings would make the code more complex for no good reason. A file in a different encoding than UTF-8 can be edited in Vim without any issue when the `encoding` option is set to `utf-8`. For instance, editing a file encoded in `latin-1` is as simple as:
```viml
:e ++enc=latin1
```
There is no need to change the `encoding` option for that.

We don't force `encoding` to be `utf-8` because changing this option is not safe after Vim start. From [the `encoding` documentation](http://vimdoc.sourceforge.net/htmldoc/options.html#'encoding'):
```
NOTE: Changing this option will not change the encoding of the
existing text in Vim.  It may cause non-ASCII text to become invalid.
It should normally be kept at its default value, or set when Vim
starts up.
```
Instead, we require this option to be set to `utf-8` when loading the plugin. If not, we tell users to put the line:
```viml
set encoding=utf-8
```
in their vimrc.

This change should only affect Vim users on Windows where `encoding` is set to `latin1` by default (`encoding` in Neovim is always `utf-8` and cannot be changed). We update the Windows installation guide accordingly.

Closes https://github.com/Valloric/YouCompleteMe/issues/2416.

<!-- 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/2691)
<!-- Reviewable:end -->
2017-06-19 16:18:41 -07:00
micbou
ea48fcffea
Require UTF-8 encoding 2017-06-19 18:00:19 +02:00
zzbot
44d4f1d299 Auto merge of #2690 - micbou:identifier-functions-codepoint, r=Valloric
[READY] Use codepoint offsets in identifier functions

`CurrentIdentifierFinished` and `LastEnteredCharIsIdentifierChar` incorrectly use byte offsets with unicode lines (`CurrentColumn` returns a byte offset and `CurrentLineContents` a unicode string). This leads to weird bugs when there is a non-ASCII character on the current line:

![unicode-identifier-bug](https://user-images.githubusercontent.com/10026824/27256590-34b27c8c-53ba-11e7-8032-b98f0c7e0b14.gif)

This is fixed by converting byte offsets to codepoint ones through the `ByteOffsetToCodepointOffset` function.

This changes the behavior of these two functions when the current column position is invalid. Both functions returned false in that case. They now return as if the current column were at the end of the line. In practice, this doesn't really matter since the position of the current column should always be valid.

<!-- 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/2690)
<!-- Reviewable:end -->
2017-06-18 12:29:13 -07:00
micbou
eb3c0cd8c1
Use codepoint offsets in identifier functions
CurrentIdentifierFinished and LastEnteredCharIsIdentifierChar incorrectly use
byte offsets with unicode lines. Convert those offsets to codepoint offsets.
2017-06-18 20:41:30 +02:00
zzbot
95ebf8666b Auto merge of #2677 - davits:diag_interface, r=micbou
[Ready] Refactored diag interface, removed dummy sign.

# PR Prelude
- [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

Removed dummy sign logic, now​ it places news signs, then removes obsolete ones. I did this in my fork long ago and never experienced any flicker.
Some source code refactoring, which I believe simplifies logic a little.

[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/2677)
<!-- Reviewable:end -->
2017-06-13 09:35:06 -07:00
Davit Samvelyan
a70755aa40 Removed current buffer caching approach. 2017-06-12 15:23:14 +04:00
Davit Samvelyan
e5b0565d1a Fixed bug: current buffer was not set correctly.
Other minor fixes.
2017-06-10 09:53:18 +04:00
Davit Samvelyan
22be4e777d Refactored diag interface, removed dummy sign. 2017-06-05 22:20:57 +04:00
zzbot
b20809332c Auto merge of #2676 - micbou:update-ycmd, r=bstaletic
[READY] Update ycmd

This include the following changes:
 - PR Valloric/ycmd#710: allow compilation for iOS projects;
 - PR Valloric/ycmd#728: handle unicode pathname when loading source on Python 2;
 - PR Valloric/ycmd#735: update JediHTTP;
 - PR Valloric/ycmd#741: update Boost to 1.64.0;
 - PR Valloric/ycmd#744: create a symlink instead of renaming libclang;
 - PR Valloric/ycmd#745: ignore identifiers from comments and strings on certain events;
 - PR Valloric/ycmd#746: ignore identifiers from comments and strings by filetype;
 - PR Valloric/ycmd#749: improve CSS identifier regex;
 - PR Valloric/ycmd#753: fix Godef build error;
 - PR Valloric/ycmd#754: search Python library in lib64 folder in addition to lib;
 - PR Valloric/ycmd#767: specify .NET Framework 4.5.

This also updates the C# instructions in the full installation guide according to PR Valloric/ycmd#767 and [`xbuild` being deprecated in favor of `msbuild` in Mono](http://www.mono-project.com/docs/about-mono/releases/5.0.0/#xbuild).

Fixes #2674.

<!-- 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/2676)
<!-- Reviewable:end -->
2017-06-05 04:59:44 -07:00
zzbot
c2906b6fef Auto merge of #2631 - davits:changedtick, r=bstaletic
[READY] Moved change tracking to python. Per buffer diagnostics

Thank you for working on YCM! :)

- [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.**

Adds an emulation of Vim buffer object and moves change tracking into python.
Now diagnostics are stored per buffer, which effectively solves #2165 .

<!-- 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/2631)
<!-- Reviewable:end -->
2017-06-05 03:21:41 -07:00
micbou
40a12d758b
Require GCC 4.9
A compiler with good enough C++11 support is required to build ycmd.
2017-06-05 11:54:06 +02:00
micbou
9c6fd9f3a7
Update C# instructions in documentation 2017-06-05 11:34:38 +02:00
micbou
7677df110c
Update ycmd
Include following changes:
 - allow compilation for iOS projects;
 - handle unicode pathname when loading source on Python 2;
 - update JediHTTP;
 - update Boost to 1.64.0;
 - create a symlink instead of renaming libclang;
 - ignore identifiers from comments and strings on certain events;
 - ignore identifiers from comments and strings by filetype;
 - improve CSS identifier regex;
 - fix Godef build error;
 - search Python library in lib64 folder in addition to lib;
 - specify .NET Framework 4.5.
2017-06-05 11:21:45 +02:00
zzbot
89beeb518e Auto merge of #2672 - micbou:restrict-coverage-package, r=bstaletic
[READY] Require coverage.py package older than version 4.4

See PR https://github.com/Valloric/ycmd/pull/770.

<!-- 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/2672)
<!-- Reviewable:end -->
2017-06-04 10:39:56 -07:00
micbou
c6ea597bd4
Require coverage.py older than 4.4
coverage.py 4.4 removed the path from the filename attribute in its reports.
This leads to incorrect coverage from codecov as it relies on this attribute to
find the source file. Require coverage.py older than version 4.4.
2017-06-04 16:42:54 +02:00
Davit Samvelyan
8c6efb4214 Cache current buffer on buffer visit. 2017-06-04 12:09:49 +04:00
Davit Samvelyan
fc745f74b3 Minor changes addressing review comments. 2017-05-29 22:24:55 +04:00
zzbot
6132f0bc50 Auto merge of #2662 - bstaletic:filepath_escaping3, r=micbou
Filepath space escaping

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.**

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

This provides the most basic test for `EscapedFilepath()`.

[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/2662)
<!-- Reviewable:end -->
2017-05-24 13:39:50 -07:00
Boris Staletic
3e77555905 Filepath space escaping 2017-05-24 17:30:15 +02:00
Davit Samvelyan
b6bbe6388f Removed unused function, added comment. 2017-05-21 19:35:01 +04:00
Davit Samvelyan
3a690fc8d4 Update based on the latest upstream changes. 2017-05-21 18:58:29 +04:00
Davit Samvelyan
0846673aa4 Latest upstream changes with buffer emulation.
Contains diagnostic interface improvents as well.
2017-05-21 18:26:50 +04:00
Davit Samvelyan
979f14acfd Moved change tracking to python. Per buffer diags 2017-05-21 11:47:27 +04:00
zzbot
263bd88bd5 Auto merge of #2650 - micbou:clean-cs-inserting-namespace-code, r=bstaletic
[READY] Clean C# inserting namespace code

Now that we require at least Vim 7.4.1578, we can remove the code that automatically insert namespaces in C# for Vim versions prior to 7.4.774.

<!-- 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/2650)
<!-- Reviewable:end -->
2017-05-19 19:19:34 -07:00
zzbot
acf9edeb1c Auto merge of #2656 - micbou:remove-allow-changing-updatetime-option, r=bstaletic
[READY] Completely remove g:ycm_allow_changing_updatetime option

Forgot to remove the `g:ycm_allow_changing_updatetime` option from `plugin/youcompleteme.vim` in PR #2636.

<!-- 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/2656)
<!-- Reviewable:end -->
2017-05-18 20:11:09 -07:00
micbou
07c04f090a
Remove g:ycm_allow_changing_updatetime option 2017-05-19 03:04:18 +02:00
micbou
1fc6b4a43b
Clean C# inserting namespace code
Remove code that automatically insert namespaces in C# for Vim versions prior
to 7.4.774.
2017-05-17 19:44:02 +02:00
zzbot
c1c4ebd7e5 Auto merge of #2636 - micbou:display-diagnostics-asynchronously, r=micbou
[READY] Display diagnostics and parse initial buffer asynchronously using timers

Currently, we wait for an autocommand to trigger to display diagnostics. This is not ideal as users have to do some actions like moving the cursor or editing the buffer to see them. We can improve that by using [the timers feature introduced in Vim 7.4.1578](975b5271ee) to display diagnostics asynchronously. Here's a demo:

![ycm-diagnostics-async](https://cloud.githubusercontent.com/assets/10026824/25772105/5aac4706-3263-11e7-8304-643a39599d29.gif)

By displaying diagnostics asynchronously, we can drop the `CursorHold` and `CursorHoldI` autocommands as well as [the `g:ycm_allow_changing_updatetime` option](5a806dcb30/README.md (the-gycm_allow_changing_updatetime-option)). In addition, we can now parse the current buffer and display diagnostics on the `TextChanged` event instead of the `CursorMoved` one. Note that we still need to check `b:changed_tick` for the `InsertLeave` event.

Given that our policy is to support the latest version of Ubuntu LTS which is 16.04, and that version [bundles Vim 7.4.1689](http://packages.ubuntu.com/xenial/vim), we can increase our Vim version requirement to 7.4.1578.

Next steps will be to use timers for parsing the buffer when the server becomes ready and for completions.

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

<!-- 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/2636)
<!-- Reviewable:end -->
2017-05-17 09:48:20 -07:00
micbou
26ac0c8730
Add syntax keywords tests
Patch EventNotification instead of BaseRequest in event notification tests.
2017-05-17 13:09:39 +02:00
micbou
3ac2951c7b
Parse current buffer when server is ready 2017-05-15 23:57:09 +02:00
micbou
d44ad0894b
Display diagnostics asynchronously
Use the timers feature to display diagnostics asynchronously instead of waiting
for an autocommand to trigger.
Increase Vim version requirement to 7.4.1578.
Drop the CursorHold and CursorHoldI autocommands.
Parse buffer on the TextChanged autocommand instead of CursorMoved.
2017-05-15 23:57:09 +02:00
zzbot
61b5aa76fe Auto merge of #2639 - micbou:faq-ycm-shutdown, r=valloric
[READY] Add FAQ entry about YCM not shutting down when quitting Vim

This issue has already been reported twice (https://github.com/Valloric/YouCompleteMe/issues/2403 and https://github.com/Valloric/YouCompleteMe/issues/2611) and is not something that we can fix on our side so we should mention it in the FAQ.

Closes https://github.com/Valloric/YouCompleteMe/issues/2611.

<!-- 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/2639)
<!-- Reviewable:end -->
2017-05-15 12:33:15 -07:00
zzbot
99be8d0226 Auto merge of #2644 - micbou:improve-reparse-requirement, r=Valloric
[READY] Improve reparse requirement on BufEnter event

When opening a file, Vim triggers the `BufRead` event then the `BufEnter` one. By setting the `s:previous_allowed_buffer_number` variable in `s:AllowedToCompleteInBuffer`, we avoid a reparse on `BufEnter` after parsing the buffer on `BufRead`. This reduces the number of `BufferVisit` and `FileReadyToParse` requests sent to the server by one when opening a file.

<!-- 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/2644)
<!-- Reviewable:end -->
2017-05-15 12:06:51 -07:00
micbou
4e08cde268
Shut down ycmd after 30 minutes of inactivity 2017-05-15 11:20:48 +02:00
zzbot
9448748e80 Auto merge of #2645 - micbou:drop-bufread-event, r=Valloric
[READY] Drop BufRead event

Since [we don't parse the buffer if no filetype is set](ad00f4c3f4/autoload/youcompleteme.vim (L334)), calling `s:OnBufferRead` on the `BufRead` event is only useful if the buffer filetype is set. But if that's the case, this means that the `FileType` event was fired before the `BufRead` one and thus the `s:OnBufferRead` function is already called. So, there is no point in calling `s:OnBufferRead` on the `BufRead` event. In fact, this costs us a `BufferVisit` and a `FileReadyToParse` request for nothing.

<!-- 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/2645)
<!-- Reviewable:end -->
2017-05-14 13:44:24 -07:00
micbou
31be11572a
Drop BufRead event
Considering that a buffer won't be parsed if no filetype is set and that it's
already parsed if the filetype is set when reading a buffer, there is no point
in parsing a buffer on the BufRead event.
2017-05-14 20:45:09 +02:00
micbou
1621c77e1d
Improve reparse requirement on buffer visit 2017-05-14 14:37:18 +02:00
zzbot
ad00f4c3f4 Auto merge of #2643 - Valloric:no-webhook, r=micbou
[READY] Removing unnecessary travis webhook

Our homu instance gets travis events through GitHub status events.

<!-- 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/2643)
<!-- Reviewable:end -->
2017-05-13 12:25:19 -07:00
Val Markovic
78dbf9be12
Removing unnecessary travis webhook
Our homu instance gets travis events through GitHub status events.
2017-05-13 12:08:45 -07:00
Val Markovic
ef1060e2db
Adding webhook for custom homu bot 2017-05-11 21:15:21 -07:00
micbou
9fd6c8e533
Add FAQ entry about YCM not shutting down 2017-05-11 02:25:06 +02:00
Homu
5a806dcb30 Auto merge of #2635 - micbou:update-autocommand-examples, r=micbou
[READY] Update autocommands examples in documentation

I am not aware of a Vim option to not switch to the location list (or quickfix) window when calling `lopen` (respectively `copen`) so I think it's a good idea to give an example in the docs on how to achieve this using the `YcmLocationOpened` and `YcmQuickFixOpened` autocommands.

Also, the `execute` calls are not needed.

<!-- 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/2635)
<!-- Reviewable:end -->
2017-05-06 07:16:42 +09:00
micbou
f7db6a1f36
Update autocommands examples 2017-05-05 21:36:47 +02:00
Homu
ba779afffb Auto merge of #2629 - micbou:force-parsing-on-buffer-visit, r=vheon
[READY] Force parsing on buffer visit

When visiting a buffer that was previously parsed, its last parse may be outdated because of changes from other buffers. We need to force a new parse.

This partially fixes issue https://github.com/Valloric/YouCompleteMe/issues/2165 in the sense that you don't have to edit the buffer (or call `:YcmForceCompileAndDiagnostics`) anymore to refresh diagnostics but you still have to wait for the `CursorHold` event. This can be further improved by displaying diagnostics asynchronously using timers.

<!-- 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/2629)
<!-- Reviewable:end -->
2017-05-03 08:30:02 +09:00
micbou
b3b393ce5a
Force parsing on buffer visit
When visiting a buffer that was previously parsed, its last parse may be
outdated because of changes from other buffers. We need to force a new parse.
2017-04-30 10:28:42 +02:00
Homu
5198fd9a09 Auto merge of #2614 - micbou:refactor-ycm-changedtick, r=Valloric
[READY] Refactor b:ycm_changedtick variable

Since we only use the `b:ycm_changedtick` variable to track the last time we parsed the buffer, we can change it to store a number instead of a dictionary.

<!-- 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/2614)
<!-- Reviewable:end -->
2017-04-12 05:38:59 +09:00
Homu
4534e9e45a Auto merge of #2613 - micbou:documentation-indentation, r=Valloric
[READY] Fix indentation in documentation

Items are not properly indented in the additional languages step of the Full Installation Guide section.

<!-- 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/2613)
<!-- Reviewable:end -->
2017-04-12 05:37:16 +09:00
micbou
51cf5f9dde
Fix indentation in documentation 2017-04-11 15:48:55 +02:00