Commit Graph

231 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
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
8c6efb4214 Cache current buffer on buffer visit. 2017-06-04 12:09:49 +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
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
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
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
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
micbou
8af0f5183e
Refactor b:ycm_changedtick variable 2017-04-11 14:09:31 +02:00
micbou
0ed21bc46e
Split OnBufferVisit again
We can't use VisitedBufferRequiresReparse for the FileType autocommand event
because ycmd may parse a buffer differently depending on its filetype.
2017-03-31 03:04:36 +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
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