[READY] Update documentation of latest python completer
I've just wrote down the first things that came to mind. So any feedback on which part to expand or fix is appreciated. Specifically I don't know if would be useful to the user to know that JediHTTP exists and what it does. I fear that explaining would do more harm than good 😕
<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/1928)
<!-- Reviewable:end -->
[READY] Fix issue in EventNotification tests
While I was reviewing PR #1905, I found an issue with the `EventNotification` tests. It's easy to reproduce. You just need to comment [this line in `python/ycm/youcompleteme.py`](https://github.com/Valloric/YouCompleteMe/blob/master/python/ycm/youcompleteme.py#L508) and run the tests. With this change, the `EventNotification` tests should fail since the second call of `ValidateParseRequest` re-raises the warning. However, tests are still passing because `assert_has_calls` does not check if a call was not made. For example, if `functionA` is called twice, both `assert_has_calls( [ functionA ] )` and `assert_has_calls( [ functionA, functionA ] )` are successful.
To fix this, we just need to check the number of calls using `call_count`. This is done by creating a subclass of `MagicMock` implementing the `assert_has_exact_calls` method and using it in tests.
<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/1927)
<!-- Reviewable:end -->
[READY] Implement new strategy to find the Python interpreter path
See discussion in issue #1891 for details.
Implement a new strategy to find the Python interpreter path:
- if specified, use `g:ycm_path_to_python_interpreter` option.
- on UNIX platforms, use `sys.executable` as the path to Python interpreter;
- on Windows, deduce it from `os.__file__` path (it should always be in the parent folder).
In all cases, check the version (2.6 or 2.7) of the Python interpreter path by running it.
This PR may break things. It needs thorough testing.
<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/1896)
<!-- Reviewable:end -->
assert_has_calls is not enough to check if a call didn't raise a
warning. We also need to check the number of calls. This is done by
creating a subclass of MagicMock implementing the
assert_has_exact_calls method.
[READY] Update get-pip.py script URL on AppVeyor
This fixes the following error on AppVeyor:
```
You're using an outdated location for the get-pip.py script, please use the one available from https://bootstrap.pypa.io/get-pip.py
```
I also changed the way `get-pip.py` is downloaded. This is now done like in the `ycmd` repository.
<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/1929)
<!-- Reviewable:end -->
Add missing implementation on OmniCompletionRequest
OmniCompletionRequest is missing the RawResponse method, so any attempt to call
it calls the base class method instead. However, since the data structures of
this class and base class are different, this causes an error.
<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/1916)
<!-- Reviewable:end -->
OmniCompletionRequest is missing the RawResponse method, so any attempt to call
it calls the base class method instead. However, since the data structures of
this class and base class are different, this causes an error.
Rename CheckPythonVersion to IsPythonVersionCorrect.
In embedders, sys.executable may contain a Vim path instead of a Python
one. To avoid starting a Vim instance in this case, we check that given
path ends with a Python 2.6 or 2.7 name using a regex.
Add tests for this regex.
If the check for available completers isn't run because the server isn't
alive, or the check request erred or times out, don't cache the result. Only
cache valid returns.
[READY] Update CMake generators for MSVC in README
Following PR Valloric/ycmd#285, older versions of CMake (< 3.0) don't support the MSVC generator names with the year component but newer versions accept both formats. So, replace the generator names in README.md by the old ones.
<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/1893)
<!-- Reviewable:end -->
[READY] Update notifications when ycmd server crashed
Instead of printing the last 30 lines of the `stderr` logfile if the server crashed, we tell the user to run the `:YcmToggleLogs stderr` command to check the logs.
Remove `SERVER_CRASH_MESSAGE_SAME_STDERR` message because we are always using the `stderr` logfile since PR #1753. Also, console ouput cannot be used to see the logs.
Simplify `_NotifyUserIfServerCrashed` method by using `CheckFilename` function from `vimsupport` module.
<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/1875)
<!-- Reviewable:end -->
This covers users that have already installed YCM before and are looking
to set up Rust completion. They're unlikely to start reading from the
Installation section, so we mention the need for the new build flag to
prevent "why doesn't it work for me" confusion.
Add support for the Rust programming language
Support for the Rust programming language is added using ycmd's racerd completer. This PR contains documentation for using the Rust completer and an update to the ycmd submodule.
## TODO
- [x] Update ycmd submodule once Valloric/ycmd#268 lands
<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/1888)
<!-- Reviewable:end -->
[READY] Fix GoTo lists arriving at the wrong column.
## Problem
When a `GoTo` command returns a list of destinations, such as declarations and definitions in Python and references in JavaScript, we pop the Vim quick fix list with a list of destinations. however, we always jump to the character before the actual declaration/definition.
## Resolution
Vim's QuickFix lists require 1-based columns, which is what is returned from ycmd's commands, so don't subtract 1 from the column number.
As noted in the comments, the Vim documentation for `setqflist` is somewhat vague about this "byte offset", but it is confirmed to mean "1-based column number" both in testing and in `:help getqflist`.
## Manual testing
Tested this with the Tern completer (`:YcmCompleter GoToReferences`) and Jedi completer (`:YcmCompleter GoToDeclaration`). For the Jedi completer, use something like:
```python
x = 1
if False:
x = 2
else:
x = 3
print( str(x) )
```
Then `:YcmCompleter GoToDeclaration` on `x`. This returns a list, which pops up the quick fix window.
*Previous behaviour*
Previously, the jump would go to the character before the actual declaration (i.e. the `<space>` before `x` in each line)
## Automated testing
Just some simple execution of the changed code, proving that we don't take 1 from the column.
<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/1876)
<!-- Reviewable:end -->
Vim's QuickFix lists require 1-based columns, which is what is returned
from ycmd's commands.
As noted in the comments, the Vim documentation for setqflist is
somewhat vague about this "byte offset", but it is confirmed to mean
"1-based column number" both in testing and in :help getqflist.
[READY] Fix traceback when v:completed_item is empty
### Problem
A traceback is raised in Vim when completing in a C♯ file while the ycmd server crashed:
```
Error detected while processing function <SNR>27_OnCompleteDone:
line 1:
Traceback (most recent call last):
Error detected while processing function <SNR>27_OnCompleteDone:
line 1:
File "<string>", line 1, in <module>
Error detected while processing function <SNR>27_OnCompleteDone:
line 1:
File "C:\\Users\\micbou\\.vim\\bundle\\YouCompleteMe\\autoload\../python\ycm\youcompleteme.py", line 305, in OnCompleteDone
Error detected while processing function <SNR>27_OnCompleteDone:
line 1:
action(self)
Error detected while processing function <SNR>27_OnCompleteDone:
line 1:
File "C:\\Users\\micbou\\.vim\\bundle\\YouCompleteMe\\autoload\../python\ycm\youcompleteme.py", line 102, in <lambda>
Error detected while processing function <SNR>27_OnCompleteDone:
line 1:
'cs': lambda( self ): self._OnCompleteDone_Csharp()
Error detected while processing function <SNR>27_OnCompleteDone:
line 1:
File "C:\\Users\\micbou\\.vim\\bundle\\YouCompleteMe\\autoload\../python\ycm\youcompleteme.py", line 428, in _OnCompleteDone_Csharp
Error detected while processing function <SNR>27_OnCompleteDone:
line 1:
Error detected while processing function <SNR>27_OnCompleteDone:
line 1:
File "C:\\Users\\micbou\\.vim\\bundle\\YouCompleteMe\\autoload\../python\ycm\youcompleteme.py", line 327, in GetCompletionsUserMayHaveCompleted
Error detected while processing function <SNR>27_OnCompleteDone:
line 1:
if self._HasCompletionsThatCouldBeCompletedWithMoreText( completions ):
Error detected while processing function <SNR>27_OnCompleteDone:
line 1:
File "C:\\Users\\micbou\\.vim\\bundle\\YouCompleteMe\\autoload\../python\ycm\youcompleteme.py", line 393, in _HasCompletionsThatCouldBeCompletedWithMoreText
_NewerVim
Error detected while processing function <SNR>27_OnCompleteDone:
line 1:
if not completed_item:
Error detected while processing function <SNR>27_OnCompleteDone:
line 1:
KeyError: 'word'
```
It happens because the Vim variable `v:completed_item` is empty. From Vim documentation on `v:completed_item`:
> Dictionary containing the complete-items for the most recently completed word after CompleteDone. **The Dictionary is empty if the completion failed**.
### Solution
Check if `v:completed_item` is empty before accessing its `word` key.
<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/1860)
<!-- Reviewable:end -->