Commit Graph

217 Commits

Author SHA1 Message Date
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
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
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
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
micbou
c349980bce
Send requests again when server becomes ready 2017-02-18 14:04:03 +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
micbou
5ece7aee9b
Remove s:GetCompletions function 2017-01-24 22:46:44 +01:00
micbou
05256d6719
Define connect timeout
Rely on connect timeout instead of checking if the server is alive.
2017-01-24 22:43:40 +01:00
micbou
c67c581d81
Always use dot operator to concatenate strings
Vim automatically adds a space between strings when concatenating them
without the dot operator. This is not obvious so we always use the dot
operator.
Minor coding style changes when writing statements on multiple lines to
be more consistent.
2017-01-01 13:57:03 +01:00
micbou
c394895c4e
Fix large file message appearing twice
Use PostVimMessage to avoid "Press ENTER or type command to continue"
message.
2016-12-31 09:53:12 +01:00
micbou
1511ee542f
Do not use BufReadPre autocommand
This autocommand has a bug that causes the cursor to move to the first
line of the current buffer when using the pedit command.
2016-12-12 21:16:06 +01:00
micbou
b93c1fd47c
Add client logfile 2016-11-19 18:47:43 +01:00
Boris Staletic
57f64dca7b Fromating and function rename 2016-11-10 21:24:09 +01:00
Boris Staletic
30def5d246 Don't set omnifunc when not allowed 2016-11-09 16:20:23 +01:00
micbou
2fabac5a67
Fix BufferUnload event notification
Send the request as the unloaded buffer instead of the current buffer
for the BufferUnload event notification. This fixes the issue where
the filetype of the current buffer is not the same as the unloaded
buffer one, making the ycmd server uses the wrong completer when
handling the request.
2016-10-08 16:43:50 +02:00
Francisco Lopes
a3ee4a5bfc Remove unused variable 2016-09-17 17:05:50 -03:00
Francisco Lopes
1b72bc2fbf Use native TextChangedI instead of an emulation.
Long and personal experience, when TextChangedI gets used, YCM seems
to perform better, diagnostics will trigger much less frequently at
inappropriate occasions, even less with whitespace agnostic triggers,
if I recall correctly...
2016-09-16 17:41:39 -03:00
micbou
981a07ded7
Handle keyboard interruption from Vim 2016-09-13 00:53:31 +02:00
micbou
aca0f21a3d
Trigger BufferVisit event only when buffer has changed
When selecting candidates during completion, Vim jumps to the preview
window (if enabled) and jumps back to the actual buffer, triggering
twice the BufEnter autocommand event. This results in YCM sending
two BufferVisit and one FileReadyToParse event notifications to
ycmd, which is completely unnecessary since the current buffer
did not change. We improve this by only sending these events when the
entered buffer allowed to be completed has changed.
2016-09-07 11:21:41 +02:00
micbou
805911b56b Use SetQuickFixList for GoTo* subcommands
Open the quickfix window to full width at the bottom of the screen with
its height set to fit all entries. This behavior can be overridden by
using the YcmQuickFixOpened autocommand.
Add a new section for autocommands in the documentation.
Update GoTo and ReplaceChunks tests.
2016-06-13 00:25:12 +02:00
micbou
e52d252d08 Revert "Don't run the plugin when in diff mode"
This reverts commit a6d5979b08.
2016-04-09 12:09:10 +02:00
Val Markovic
eb8a24f23d Addressing review comments 2016-02-29 10:26:50 -08:00
Val Markovic
b04870c824 VimL support for py3 2016-02-28 13:54:49 -08:00
micbou
3cf6fa86f5 Rewrite SetUpPython function
Do not create YouCompleteMe object if setup failed. Use a try/except
block to prevent backtraces in Vim.
2016-02-24 17:56:31 +01:00
Val Markovic
f986bf19db Updating to latest ycmd 2016-02-22 09:50:15 -08:00
Davit Samvelyan
4d97437872 Moved parse request and diagnostics handling to python.
Moved File parse request handling and diagnostic extraction flow into
python to simplify flow and allow easier addition of new parse request
handlers such as semantic highlighter.
Refactored base_test to patch separate vimsupport functions instead of
the whole module, and interfering the test results afterwards.
Added new tests for diagnostic sign place/unplace and error/warning
count extraction API.
2016-02-21 14:47:54 +04:00
Andrea Cedraro
ad4091635e Add comment expaning why we defer setting the omnifunc 2015-12-31 00:12:38 +01:00
Andrea Cedraro
b4beed4939 Defer setting the omnifunc only the first time
Fix #1769
2015-12-30 14:41:38 +01:00
Ben Jackson
861546fac0 Display errors raised by OnFileReadyToParse in non-diagnostics filetypes 2015-12-20 17:27:17 +00:00
Kenny Kaye
bb8490e6c7 Properly namespace vim warning/error getters 2015-12-05 09:24:15 -08:00
Kenny Kaye
dafc36ba37 Expose functions to get error and warning counts 2015-12-04 14:45:11 -08:00
micbou
9ce4e31718 Do not capitalize :YcmToggleLogs argument
stdout and stderr names are rarely capitalized.
2015-11-11 14:15:01 +01:00
micbou
cbe3e04745 Add :YcmToggleLogs command 2015-11-08 18:43:52 +01:00
micbou
290a65219f Define Vim commands only if setup is successful 2015-10-12 15:27:30 +02:00
micbou
87854f0245 Move PathToPythonInterpreter function to YCM
Create a module for paths.
2015-10-09 18:53:24 +02:00
Spencer G. Jones
9f568be39a fixup! Add CompleteDone hook, with namespace insertion for C# 2015-08-31 10:51:23 -06:00
Spencer G. Jones
dd27184970 Add CompleteDone hook, with namespace insertion for C#
Add a new vim hook on CompleteDone. This hook is called when a
completions is selected.

When forcing semantic completion with the keybind, C# completions can
return a list of importable types. These types are from namespaces which
havn't been imported, and thus are not valid to use without also adding
their namespace's import statement. This change makes YCM automatically
insert the necessary using statement to import that namespace on
completion completion. In the case there are multiple possible
namespaces, it prompts you to choose one.
2015-08-28 10:05:46 -06:00
micbou
037bd0f6f1 Fix trigger issues
Fix the following cases where the completion is not triggered for
the next typed character:
 - moving vertically in insert mode,
 - removing a character and entering insert mode.
2015-08-03 22:32:57 +02:00
Strahinja Val Markovic
5796f52797 Whitespace fixes 2015-07-02 14:32:27 -07:00
Strahinja Val Markovic
98d687a5e0 Updating to latest ycmd
Related to Valloric/ycmd#171
2015-07-01 17:52:51 -07:00
Andrea Cedraro
7bc05a37b5 Fix check condition for setting omnifunction 2015-06-18 14:08:06 +02:00
Andrea Cedraro
4104f7be82 Push check for NativeFiletypeCompletionUsable down
Another way in which the commit d768447 forced the client to wait for
the server to start was the UpdateDiagnosticNotifications call from the
FileReadyToParse which is called right after a buffer is loaded. In any
way if we don't have any previous FileReadyToParse request done for the
current file we bail out, so we we can wait for a FileReadyToParse
response to be available before asking if a completer is usable for the
current filetype.

ref: #1529
2015-06-15 16:08:56 +02:00
Andrea Cedraro
30036ca8e2 Defer setting the omnifunc.
When we enter a new buffer we need to know if the ycmd server has a
native completer for the current filetype, this means that when we start
vim we need to know if the server has a completer available for the
buffer which means that we have to wait for the server to be up and
running. To mitigate this defer the setting of the omnifunction closer
to its need which is when we enter insert mode; this should give room
for the ycmd server to start before we ask for anything or at least
should reduce the time waiting.

ref: #1529
2015-06-15 16:08:50 +02:00
Frankie Robertson
63a7aa9daf Remap <Nul> to <C-Space> regardless of gui_running since it is an unreliable way of detecting terminals in neovim 2015-06-03 14:33:56 +03:00
Andrea Cedraro
e28c709b99 Disable on large file
closes #1238
2014-12-05 10:32:52 +01:00
Spencer G. Jones
ac3a48de70 Unlike the other functions, youcompleteme#EnableCursorMovedAutocommands and youcompleteme#DisableCursorMovedAutocommands are not overwriting. This causes an error if the file is reloaded. 2014-10-14 11:11:33 -06:00
Strahinja Val Markovic
7cb41a20ac Moved some code around 2014-09-15 12:39:05 -07:00
Husak Kristijan
8e14914602 Remove commands for lock and unlock. 2014-09-15 12:37:18 -07:00
Husak Kristijan
abdf38a055 Change function names and make them public. 2014-09-15 12:37:17 -07:00
Husak Kristijan
2be6adda06 Add functionality for disabling and enabling Ycm autocompletion. 2014-09-15 12:37:17 -07:00