Commit Graph

250 Commits

Author SHA1 Message Date
micbou
bdc3a66488
Ignore ft= argument from YcmCompleter command
Only the "ycm:ident" value of the ft= argument in the YcmCompleter
command is working. This value forces the use of the identifier
completer which serve no purpose because this completer doesn't define
commands. Ignore completely the ft= argument and move the logic to the
Python layer.
2018-09-28 01:12:23 +02:00
micbou
959d0c4c5f
Only use command modifiers if available
Command modifiers were added in Vim 7.4.1898.
2018-08-14 13:52:25 +02:00
micbou
87702559f3
Support modifiers for GoTo commands 2018-07-24 18:07:41 +02:00
midchildan
23771b379a
Add CUDA support 2018-05-24 14:34:15 +09:00
micbou
d16d3cebc4
Allow users to change the options by restarting the server 2018-05-15 23:45:54 +02:00
micbou
a24d97ca6b
Resend request when extra conf is loaded or ignored
When the client sends a request to the server, if an extra conf file is found
that is not already white/blacklisted, the server stops processing the request
and tells the client that an unknown extra conf file has been found. The client
then asks the user if that file should be loaded or not. Depending on the
user's answer, the client sends a request to the server to load or ignore the
extra conf file. Finally, the server loads the file or adds it to the
blacklist. However, the initial request was not processed by the server and
should be sent again.
2018-04-22 22:10:14 +02:00
micbou
6f9366d150
Check if completion is allowed on character events 2018-04-02 22:16:47 +02:00
micbou
c84e70737c
Improve diagnostic matches display 2018-02-18 21:32:00 +01:00
micbou
0f1d7706fe
Replace <range> with <count> in YcmCompleter command
<range> was introduced in Vim 8.0.1089. Use <count> instead.  It returns -1
when no range is given.
2018-02-13 12:06:14 +01:00
micbou
a13329fe94
Add range support to completer command 2018-02-12 01:50:08 +01:00
Ben Jackson
292de25c72 Add support for Java diagnostics and asynchronous messages
This implements an asynchronous message system using a long-poll request
to the server.

The server provides an endpoint /receive_messages which blocks until
either a timeout occurs or we receive a batch of asynchronous messages.
We send this request asynchronously and poll it 4 times a second to see
if we have received any messages.

The messages may either be simply for display (such as startup progress)
or diagnostics, which override the diagnostics returned by
OnFileReqdyToParse.

In the former case, we simply display the message, accepting that this
might be overwritten by any other message (indeed, requiring this), and
for the latter we fan out diagnostics to any open buffer for the file in
question.

Unfortunately, Vim has bugs related to timers when there is something
displayed (such as a "confirm" prompt or other), so we suspend
background timers when doing subcommands to avoid vim bugs. NOTE: This
requires a new version of Vim (detected by the presence of the
particular functions used).
2018-02-10 16:29:27 +00:00
micbou
43ebd5252d
Optimize request building
Reduce the time spent to build the request when there are a lot of buffers by:
 - using the options property on the buffer object to get the mod variable
instead of evaluating getbufvar;
 - not computing the buffer filepath if the buffer is not modified;
 - passing the number of the unloaded buffer instead of its filepath on the
   BufferUnload event. Getting the Python buffer object from its number is
   easier than from its filepath.
2018-01-09 01:40:07 +01:00
micbou
7e2e1e7d34
Only call completefunc if needed
Do not call user's completion function if the start column is after the current
column or if there are no candidates. This avoids keeping the user in
completion mode even if there is no completion menu.
2017-11-15 18:51:55 +01:00
micbou
2b8e86797c
Improve server crash notification at startup
Notify the user if the server crashed during server polling at startup.
2017-10-05 13:12:23 +02:00
micbou
04f6497462
Insert keys at the start of the typeahead buffer
When sending keys to Vim, they are by default added to the end of the typeahead
buffer. If there are already keys in the buffer, they will be processed first
and may change the state that our keys combination was sent for (e.g.
<C-X><C-U><C-P> in normal mode instead of insert mode or <C-e> outside of
completion mode). We avoid that by inserting the keys at the start of the
typeahead buffer.
2017-07-31 10:58:40 +02:00
micbou
5cd560c021
Check completefunc when forcing semantic completion
Vim returns an error when forcing semantic completion and the completefunc is
not set.
2017-07-20 21:52:08 +02:00
zzbot
bd302907f5 Auto merge of #2704 - micbou:stop-polling-if-server-crashed, r=bstaletic
[READY] Stop polling for readiness if the server crashed

There is no need to continue polling the server if its process has terminated (i.e. the server crashed). This fixes issue https://github.com/Valloric/YouCompleteMe/issues/2683 when the server is not working.

<!-- 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/2704)
<!-- Reviewable:end -->
2017-07-05 01:28:17 -07:00
micbou
1ceabea26e
Stop polling for readiness if server crashed 2017-07-05 05:19:47 +02:00
micbou
63bc2fb6e8
Stop completion polling on InsertLeave event 2017-07-05 04:46:05 +02:00
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