Commit Graph

2493 Commits

Author SHA1 Message Date
Homu
03ba8a80cd Auto merge of #2590 - micbou:python-executable-capitalized, r=Valloric
[READY] Accept capitalized name for Python executable

I was looking at `PathToPythonInterpreter` coverage and was surprised to see [that line](
01570aac03/python/ycm/paths.py (L84)) covered. This shouldn't be the case since we are supposed to use the Python from `PYTHON_USED_DURING_BUILDING`. This happens because the Python executable used in our Travis builds on macOS is named `Python` (with a capital letter) and so we don't accept it.

<!-- 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/2590)
<!-- Reviewable:end -->
2017-03-28 19:13:42 +09:00
micbou
fb000ca9e7
Accept capitalized name for Python executable
Python executable name may be capitalized on macOS.
2017-03-28 02:12:15 +02:00
micbou
2542105e2f
Merge s:OnBufferRead and s:OnBufferEnter
Fix issue where completeopt, completefunc, and omnifunc are not set for buffers
opened before the plugin is loaded.
2017-03-27 23:49:09 +02:00
Homu
01570aac03 Auto merge of #2585 - micbou:remove-python-check, r=Valloric
[READY] Remove Python version check

Even with the `-S` option (see PR https://github.com/Valloric/YouCompleteMe/pull/2502), starting the Python interpreter to check its version can be slow. For instance, on my machine (in PowerShell):
```ps
> Measure-Command -Expression {python -S -c "pass"}
...
TotalMilliseconds : 25,4387
```
It's also not particularly useful because, in the typical case, the Python used to start ycmd will be the one from `PYTHON_USED_DURING_BUILDING` which is necessarily a supported version. In the cases where the `g:ycm_server_python_interpreter` option is specified or a Python is found in the PATH, it's up to the user to provide a supported version. If they don't, the ycmd server will probably fail to start and the following error will be displayed to them:
```
The ycmd server SHUT DOWN (restart with ':YcmRestartServer'). Unexpected exit code 1. Use the ':YcmToggleLogs' command to check the logs.
```
They can then look at the logs to understand what went wrong.
Finally, the last case is when the Python is the one used by YCM itself. In that case, if the Python version is not supported, it will fail before doing the check so it doesn't matter.

As always, here are the improvements on startup time:
<table>
  <tr>
    <th rowspan="2">Platform</th>
    <th colspan="2">First run (ms)</th>
    <th colspan="2">Subsequent runs (ms)</th>
  </tr>
  <tr>
    <td>Before</td>
    <td>After</td>
    <td>Before</td>
    <td>After</td>
  </tr>
  <tr>
    <td>Ubuntu 16.04 64-bit</td>
    <td>147</td>
    <td>134</td>
    <td>74</td>
    <td>65</td>
  </tr>
  <tr>
    <td>macOS 10.12</td>
    <td>189</td>
    <td>165</td>
    <td>127</td>
    <td>107</td>
  </tr>
  <tr>
    <td>Windows 10 64-bit</td>
    <td>242</td>
    <td>200</td>
    <td>147</td>
    <td>115</td>
  </tr>
</table>

*Results obtained by running the `prof.py` script from [this branch](https://github.com/micbou/YouCompleteMe/tree/profiling-startup) on Python 3.6.*

<!-- 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/2585)
<!-- Reviewable:end -->
2017-03-27 01:57:02 +09:00
micbou
f84796bf0e
Remove Python version check
Starting the Python interpreter to check its version is slow.
2017-03-25 18:27:07 +01:00
Homu
53e4de0e36 Auto merge of #2584 - mikeperri:typescript-diagnostics, r=micbou
Typescript diagnostics

# 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
This just makes use of [these changes](https://github.com/Valloric/ycmd/pull/718) to ycmd.
It adds TypeScript to the list of filetypes that diagnostics are supported for and reflects that in the README. (And updates ycmd.)
No tests are included, since the only code that changed is the hard-coded list of filetypes. The new ycmd functionality is tested in that project.

<!-- 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/2584)
<!-- Reviewable:end -->
2017-03-26 01:14:25 +09:00
Mike Perri
39dea3c3b4 Update ycmd version 2017-03-25 11:22:05 -04:00
Mike Perri
656ddc34e3 Enable diagnostics for TypeScript and update README 2017-03-25 11:22:02 -04:00
Homu
32ea947dd0 Auto merge of #2578 - micbou:urllib-compatibility, r=Valloric
[READY] Import urljoin and urlparse from ycmd.utils

See https://github.com/Valloric/ycmd/pull/724. This also fixes a regression in startup time on Python 3 because importing `futures.moves` was calling [the `import_top_level_modules` function](https://github.com/PythonCharmers/python-future/blob/master/src/future/moves/__init__.py#L7-L8) which is slow.

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

<!-- 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/2578)
<!-- Reviewable:end -->
2017-03-21 05:46:15 +09:00
micbou
e581c5c8ab
Import urljoin and urlparse from ycmd.utils 2017-03-20 10:59:20 +01:00
Homu
46ee48432d Auto merge of #2575 - micbou:remove-install-aliases, r=Valloric
[READY] Do not install aliases from future

Depends on PR https://github.com/Valloric/ycmd/pull/722. This improves startup time on Python 2:

<table>
  <tr>
    <th rowspan="2">Platform</th>
    <th colspan="2">First run (ms)</th>
    <th colspan="2">Subsequent runs (ms)</th>
  </tr>
  <tr>
    <td>Before</td>
    <td>After</td>
    <td>Before</td>
    <td>After</td>
  </tr>
  <tr>
    <td>Ubuntu 16.04 64-bit</td>
    <td>245</td>
    <td>162</td>
    <td>134</td>
    <td>103</td>
  </tr>
  <tr>
    <td>macOS 10.12</td>
    <td>314</td>
    <td>202</td>
    <td>192</td>
    <td>136</td>
  </tr>
  <tr>
    <td>Windows 10 64-bit</td>
    <td>659</td>
    <td>384</td>
    <td>257</td>
    <td>154</td>
  </tr>
</table>

*Results obtained by running the `prof.py` script from [this branch](https://github.com/micbou/YouCompleteMe/tree/profiling-startup).*

Fixes #2332.
Fixes #2467.
Fixes #2568.

<!-- 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/2575)
<!-- Reviewable:end -->
2017-03-19 07:02:11 +09:00
micbou
41fb6537e2
Update ycmd
Changelog:
 - update Clang to 4.0.0;
 - startup improvement.
2017-03-18 18:25:43 +01:00
micbou
f3ccafe3ae
Do not install aliases from future
Installing aliases from python-future is unreliable and slow.
2017-03-18 18:24:48 +01:00
Andrey Pikas
2495dffa59 Fix tests under Windows. 2017-03-12 23:06:05 +03:00
Andrey Pikas
822010fe4c Move import to the top of file. 2017-03-12 20:18:24 +03:00
Homu
6583da75bd Auto merge of #2572 - micbou:update-ycmd, r=vheon
[READY] Update ycmd

Release notes:
 - PR https://github.com/Valloric/ycmd/pull/707: update racerd;
 - PR https://github.com/Valloric/ycmd/pull/709: update Tern to 0.21.0;
 - PR https://github.com/Valloric/ycmd/pull/711: fix https://github.com/Valloric/YouCompleteMe/issues/2532;
 - PR https://github.com/Valloric/ycmd/pull/717: add Visual Studio 2017 and drop Visual Studio 2012 support.

Closes #2571.

<!-- 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/2572)
<!-- Reviewable:end -->
2017-03-13 01:47:54 +09:00
Andrey Pikas
592b85516b Tests for checking that extra_conf_data sended to server from :DebugInfo and :YcmCompleter commands. 2017-03-12 19:03:07 +03:00
micbou
edf7e600c8
Update ycmd
Release notes:
 - update racerd;
 - update Tern to 0.21.0;
 - fix finding node on Debian-based distributions;
 - add Visual Studio 2017 support;
 - drop Visual Studio 2012 support.
2017-03-12 12:03:50 +01:00
Andrey Pikas
3db1413cd9 Send extra_conf_vim_data in requests from :YcmCompleter and :YcmDebugInfo commands. It's needed for passing compile_commands.json directory to every call of FlagsForFile in client_data argument. 2017-03-11 13:34:37 +03:00
Homu
650a19ba0a Auto merge of #2565 - idvoretskyi:patch-1, r=micbou
Indents added in Ubuntu and Fedora sections

# 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

Indents added in Ubuntu section (for easier copy&pasting).

PS. Tests are not included - minor documentation change.

[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/2565)
<!-- Reviewable:end -->
2017-03-09 17:46:15 +09:00
Homu
e107855edd Auto merge of #2569 - micbou:server-stderr-unicode, r=Valloric
[READY] Convert stderr from server to unicode

On Python 3, reading stderr from server returns bytes. We need to convert it to unicode for `splitlines()`.

<!-- 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/2569)
<!-- Reviewable:end -->
2017-03-09 08:19:54 +09:00
Ihor Dvoretskyi
93955fc5e5 Trailing spaces removed 2017-03-08 20:48:48 +02:00
micbou
7e31634072
Convert stderr from server to unicode
On Python 3, reading stderr from server returns bytes. We need to convert it to
unicode for splitlines.
2017-03-08 17:30:00 +01:00
Ihor Dvoretskyi
55e7bc1674 Cleanup 2017-03-07 16:44:42 -08:00
Ihor Dvoretskyi
905c2a5a1d Indents added in Fedora section 2017-03-07 16:43:56 -08:00
Homu
cb2f6d7953 Auto merge of #2566 - micbou:python3, r=puremourning
[READY] Prefer Python 3 over Python 2

When both versions are available, we should use Python 3 over Python 2 for the following reasons:
 - faster startup:

<table>
  <tr>
    <th rowspan="2">Platform</th>
    <th colspan="2">First run (ms)</th>
    <th colspan="2">Subsequent runs (ms)</th>
  </tr>
  <tr>
    <td>Python 2</td>
    <td>Python 3</td>
    <td>Python 2</td>
    <td>Python 3</td>
  </tr>
  <tr>
    <td>Ubuntu 16.04 64-bit</td>
    <td>197</td>
    <td>110</td>
    <td>117</td>
    <td>84</td>
  </tr>
  <tr>
    <td>macOS 10.12</td>
    <td>322</td>
    <td>186</td>
    <td>210</td>
    <td>124</td>
  </tr>
  <tr>
    <td>Windows 10 64-bit</td>
    <td>601</td>
    <td>295</td>
    <td>251</td>
    <td>144</td>
  </tr>
</table>

*Results obtained by running the `prof.py` script from [this branch](https://github.com/micbou/YouCompleteMe/tree/profiling-startup). The difference between first run and subsequent runs is Python bytecode generation (`*.pyc` files).*

These differences are due to `python-future` monkey-patching a lot of stuff on Python 2 but not on Python 3;

 - better Windows support. For instance, [the `tempfile` module returns temporary paths in all lowercase on Python 2](https://bugs.python.org/issue14255) (we use it to create our logfiles). This is fixed on Python 3.
 - [Python 2 support will be dropped in 2020](https://docs.python.org/devguide/index.html#branchstatus).

<!-- 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/2566)
<!-- Reviewable:end -->
2017-03-07 16:45:57 +09:00
micbou
b3e6bad6b1
Prefer Python 3 over Python 2
When both versions are available, we prefer Python 3 over Python 2:
 - faster startup (no monkey-patching from python-future);
 - better Windows support (e.g. temporary paths are not returned in all
   lowercase);
 - Python 2 support will eventually be dropped.
2017-03-06 23:19:30 +01:00
Ihor Dvoretskyi
25bff655e1 Indents added in Ubuntu section
Indents added in Ubuntu section (for easier copy&pasting)
2017-03-06 21:49:36 +02:00
Homu
0cc761fe00 Auto merge of #2561 - micbou:always-defer-startup, r=Valloric
[READY] Always defer loading at VimEnter

YCM should start the same whether Vim is running in GUI or not. Otherwise, this makes it difficult for other plugins to interact with YCM at startup because they can't predict how YCM will start unless they also check if Vim is running in GUI which is unreasonable. Since we can't load it at Vim startup because of [a deadlock issue](https://github.com/Valloric/YouCompleteMe/pull/2473#issuecomment-267716136), we should always defer it at the VimEnter event.

See discussion in 39659caf34 for more details.

<!-- 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/2561)
<!-- Reviewable:end -->
2017-03-07 03:40:32 +09:00
Homu
6a7d219526 Auto merge of #2563 - micbou:import-requests-lazily, r=puremourning
[READY] Import the requests module lazily

The requests module is slow to import. See https://github.com/kennethreitz/requests/issues/3213. We should lazy load it to improve startup time. We do that by adding two methods to the `BaseRequest` class: one that returns the requests module and another the session object since it depends on the `request-futures` module and `requests-futures` imports `requests`. In addition, we make sure that no requests are sent at startup otherwise there would be no point to lazy load these. These requests would fail anyway since the server can't be ready yet.

Here are the improvements on startup time:
<table>
  <tr>
    <th rowspan="2">Platform</th>
    <th colspan="2">First run (ms)</th>
    <th colspan="2">Subsequent runs (ms)</th>
  </tr>
  <tr>
    <td>Before</td>
    <td>After</td>
    <td>Before</td>
    <td>After</td>
  </tr>
  <tr>
    <td>Ubuntu 16.04 64-bit</td>
    <td>240</td>
    <td>131</td>
    <td>173</td>
    <td>74</td>
  </tr>
  <tr>
    <td>macOS 10.12</td>
    <td>435</td>
    <td>315</td>
    <td>261</td>
    <td>208</td>
  </tr>
  <tr>
    <td>Windows 10 64-bit</td>
    <td>894</td>
    <td>594</td>
    <td>359</td>
    <td>247</td>
  </tr>
</table>

*Results obtained by running the `prof.py` script from [this branch](https://github.com/micbou/YouCompleteMe/tree/profiling-startup). The difference between first run and subsequent runs is Python bytecode generation (`*.pyc` files).*

<!-- 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/2563)
<!-- Reviewable:end -->
2017-03-06 10:58:34 +09:00
micbou
09a08d3240
Import requests module lazily
The requests module is slow to load so we should import it only when needed to reduce startup time.
2017-03-04 03:21:58 +01:00
micbou
c31152d345
Always defer loading at VimEnter
YCM should start the same whether Vim is running in GUI or not. Otherwise, this
makes it difficult for other plugins to interact with YCM at startup because
they can't predict how YCM will start unless they also check if Vim is running
in GUI which is unreasonable. Since we can't load it at Vim startup because of
a deadlock issue, we should always defer it at the VimEnter event.
2017-03-02 21:48:56 +01:00
Homu
39659caf34 Auto merge of #2554 - micbou:gui-running, r=puremourning
[READY] Use gui_running instead of gui to defer YCM loading at VimEnter

`has('gui')` returns `1` even in console Vim if it is compiled with `+gui`. We should use `gui_running` instead. See 1d1a4f4cff (commitcomment-20876179).

<!-- 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/2554)
<!-- Reviewable:end -->
2017-02-27 07:23:06 +09:00
micbou
cd79e99746
Use gui_running instead of gui
has('gui') returns 1 even in console Vim if it is compiled with +gui.
2017-02-22 14:20:46 +01:00
Homu
83aea2fbe8 Auto merge of #2548 - micbou:clear-compilation-message, r=Valloric
[READY] Refactor diagnostic commands

This PR moves the logic of the `YcmDiags` and `YcmForceCompileAndDiagnostics` commands to the Python layer. It replaces the `echo` calls by `PostVimMessage` ones to display message on the status line and it always prints `Diagnostics refreshed` once compilation is done. This has the benefit of clearing the message `Forcing compilation, this will block Vim until done.` and avoiding the `Press Enter or type command to continue` prompt.

This also adds the `YcmLocationOpened` autocommand which is the same as `YcmQuickFixOpened` but for the location list window.

Fixes #2543.

<!-- 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/2548)
<!-- Reviewable:end -->
2017-02-21 02:36:57 +09:00
micbou
414782bc74
Add tests for diagnostic commands 2017-02-20 18:28:49 +01:00
micbou
0d476a0164
Refactor diagnostic commands
Move s:ShowDiagnostics and s:ForceCompileAndDiagnostics logic to the Python layer.
Clear message about compilation blocking Vim once it is done.
2017-02-20 18:28:49 +01:00
Homu
164165f0c8 Auto merge of #2547 - micbou:server-becomes-ready, r=vheon
[RFC] Send requests again when server becomes ready

Since PR #2517, the `BufferVisit` and `FileReadyToParse` requests are ignored until the server is ready. We need to send them again when it becomes ready so that identifiers and snippets for the current buffer are properly parsed. This is done in the `s:OnFileReadyToParse` function since this function is regularly called. We also try to set the omnifunc since it depends on a response from the server and is only set when entering a buffer or changing its filetype. This replaces the code that consisted of setting the omnifunc when entering insert mode for the first time.

A cleaner solution would be to do that asynchronously but we can't with our Vim version requirement.

Fixes #2541.

<!-- 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/2547)
<!-- Reviewable:end -->
2017-02-19 10:13:08 +09:00
micbou
c349980bce
Send requests again when server becomes ready 2017-02-18 14:04:03 +01:00
Homu
1d1a4f4cff Auto merge of #2475 - wincent:still-a-little-lazy, r=Valloric
Don't use VimEnter initialization except when stating gui

# 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

This is another attempt at:

https://github.com/Valloric/YouCompleteMe/pull/2473

Which removed the apparently flawed attempt at "lazy" loading of YCM. While it fails to get the load out of the critical startup path, it *does* serve the useful purpose when starting up gvim of avoiding a deadlock situation in gvim.

So, this time, we keep VimEnter, but only for the gui-starting case. We update the comment to explain what is actually happening. And we can keep the docs about how to defer loading.

[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/2475)
<!-- Reviewable:end -->
2017-02-11 06:48:25 +09:00
Greg Hurrell
878d329e8f Fix whitespace 2017-02-09 14:46:36 -08:00
Homu
c881441385 Auto merge of #2531 - tqoitc:master, r=micbou
Updated ycmd to ec7a154 to fix racerd build issues

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

Building racerd fails with the current submodule version of ycmd. This updates ycmd to the latest commit (ec7a154 at the time of writing) and fixes racerd failing to build. No additional tests were included because this is an update a library with its own tests.

Closes #2480.

[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/2531)
<!-- Reviewable:end -->
2017-02-09 05:01:23 +09:00
Lucas Salibian
f2235be62c Updated ycmd to ec7a154 to fix racerd build issues 2017-02-07 15:57:28 -08:00
Homu
68d78719a4 Auto merge of #2520 - vheon:fix-togglelogs, r=micbou
Use bang version of `normal`

Fixes #2519

# 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

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

[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/2520)
<!-- Reviewable:end -->
2017-02-02 09:48:36 +09:00
Andrea Cedraro
fda5c7e6c6 Use bang version of normal
Fixes #2519
2017-01-31 22:09:40 +01:00
Homu
f6867340dd Auto merge of #2517 - micbou:remove-healthy-check, r=Valloric
[READY] Remove healthy check

This PR removes the code that, if the server is not yet healthy, tries in a separate thread to send the same request at different intervals until it gets a response or reaches 5 failed attempts.

Main issue with that code is that it blocks Vim if a synchronous request (`semantic_completion_available`, `run_completer_command`, etc.)  is sent while the server is not up. See issue #2071.

Other issues are that it's hard to understand how this code behaves (it combines threads and retries), it becomes useless once the server is healthy (because `SERVER_HEALTHY` is cached and never reset), it depends on arbitrary parameters (why 5 retries with a delay of 0.5s multiplied by 1.5 at each attempt?), and it has a package dependency `retries`.

Now that we catch all server exceptions (PR #2453) and define a very short connection timeout (PR #2514), we can just drop this code.

This change gives a huge improvement in startup time on Windows (don't worry, more improvements are coming for all platforms). The reason is that `requests` (probably `urllib3`) tries for ~1s to check if the server is healthy on Windows while it's almost instantaneous on other platforms.
<table>
  <tr>
    <th rowspan="2">Platform</th>
    <th colspan="2">First run (ms)</th>
    <th colspan="2">Subsequent runs (ms)</th>
  </tr>
  <tr>
    <td>Before</td>
    <td>After</td>
    <td>Before</td>
    <td>After</td>
  </tr>
  <tr>
    <td>Ubuntu 16.04 64-bit</td>
    <td>228</td>
    <td>248</td>
    <td>176</td>
    <td>151</td>
  </tr>
  <tr>
    <td>macOS 10.12</td>
    <td>433</td>
    <td>417</td>
    <td>263</td>
    <td>263</td>
  </tr>
  <tr>
    <td>Windows 10 64-bit</td>
    <td>1861</td>
    <td>844</td>
    <td>814</td>
    <td>292</td>
  </tr>
</table>

These results were obtained by running the `prof.py` script from [this branch](https://github.com/micbou/YouCompleteMe/tree/profiling-startup). The difference between first run and subsequent runs is Python bytecode generation (`*.pyc` files).

Fixes #2071.

<!-- 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/2517)
<!-- Reviewable:end -->
2017-01-29 08:53:07 +09:00
micbou
10aba99782
Remove healthy check 2017-01-28 16:54:33 +01:00
Homu
410a4b6a82 Auto merge of #2516 - micbou:connection-error, r=Valloric
[READY] Catch ConnectionError instead of ConnectTimeout

On non-Windows platforms (tested on Linux and OS X), a `ConnectionError` exception is raised instead of a `ConnectTimeout` one when the connection cannot be established (e.g. the server crashed). Since [the latter is a subclass of the former](http://docs.python-requests.org/en/master/_modules/requests/exceptions/#ConnectTimeout), we only need to catch `ConnectionError`.

<!-- 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/2516)
<!-- Reviewable:end -->
2017-01-28 18:05:18 +09:00
micbou
6e8aeeac15
Catch ConnectionError instead of ConnectTimeout
On non-Windows platforms, a ConnectionError exception is raised instead
of a ConnectTimeout one when the connection cannot be established (e.g.
the server crashed). Since the latter is a subclass of the former, we
only need to catch ConnectionError.
2017-01-27 03:33:43 +01:00
Homu
dc44597674 Auto merge of #2514 - micbou:connect-timeout, r=Valloric
[READY] Rely on connect timeout instead of checking that the server is alive

Currently, we always check that the ycmd process is up (with the `IsServerAlive` method) before sending a request. Without this check, each request could block Vim until a `NewConnectionError` exception is raised if the server crashed. This is the case on Windows where it takes ~1s before the exception is raised which makes Vim unusable. However, even with this check, Vim may still be blocked in the following cases:
 - the server crashes just after the check but before sending the request;
 - the server is up but unresponsive (e.g. its port is closed).

To avoid both cases, we instead use [the connect timeout parameter from Requests](http://docs.python-requests.org/en/master/user/advanced/?highlight=connect%20timeout#timeouts) and set it to a duration sufficiently short (10 ms) that the blocking can't be noticed by the user. Since the server is supposed to run locally (this is what YCM is designed for), 10ms is largely enough to establish a connection.

The `IsServerAlive` check is removed almost everywhere except in `OnFileReadyToParse` because we still want to notify the user if the server crashed.

This change makes it possible to not have to [wait for the server to be healthy before sending asynchronous requests](https://github.com/Valloric/YouCompleteMe/blob/master/python/ycm/client/base_request.py#L137-L138). This will dramatically improve startup time (see issue #2085) and fixes #2071. Next PR once this one is merged.

<!-- 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/2514)
<!-- Reviewable:end -->
2017-01-26 19:01:59 +09:00