Commit Graph

261 Commits

Author SHA1 Message Date
micbou
f3ce1d12bd
Allow completion in the command-line window 2019-02-05 20:48:06 +01:00
micbou
f58d9d607e
Do not call OnCompleteDone on blacklisted filetypes 2019-01-23 00:49:59 +01:00
Chih-Hsuan Yen
67c39a3330
Workaround "Invalid channel" errors when NeoVim exits immediately after started
The idea is from https://github.com/neovim/neovim/issues/6840#issuecomment-309960751

Thanks micbou!
2019-01-17 01:36:22 +08:00
micbou
3b9fef4e2a
Support virtualenv and embedded Python 2018-12-30 19:01:45 +01:00
micbou
88504eb44a
Remove server_utils dependency 2018-12-19 13:54:23 +01:00
Boris Staletic
5c12f5e357 Separate YCM/ycmd submodules 2018-12-11 00:42:39 +01:00
micbou
e651d970ed
Remove user_options_store dependency
Directly define the ycmd options in the plugin.
2018-11-26 12:51:01 +01:00
micbou
eba717553f
Recompute starting column on auto-wrapping
When auto-wrapping is enabled, Vim wraps the current line after the
completion request is sent but before calling the completefunc. The
starting column returned by the server is invalid in that case and must
be recomputed.
2018-11-17 01:07:02 +01:00
zzbot
75c3bb6928
Auto merge of #3124 - hackaugusto:type_check_blacklist, r=micbou
added type check for g:ycm_filetype_blacklist

# 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

I made a mistake while configuring ycm and used a list instead of a ditionary for the blacklist, like so:

```vim
let g:ycm_filetype_blacklist = ['python']
```

If the `CursorMoved` autocmd is installed while the configuration is not a dictionary, an error message is raised after every keystroke, this makes fixing the configuration error a bit painful. Error message:

```
Error detected while processing function <SNR>78_OnCursorMovedNormalMode[1]..<SNR>78_AllowedToCompleteInCurrentBuffer[1]..<SNR>78_AllowedToCompleteInBuffer:
line   15:
E715: Dictionary required
```

This PR just adds a check for the type of the variable `g:ycm_filetype_blacklist`, if it's  the wrong type a message is printed and the autocmd is not installed. The check was done inside `Enable` to ensure the init.vim had fully executed.

[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/3124)
<!-- Reviewable:end -->
2018-10-14 09:20:07 -07:00
micbou
040582c107
Add minimal dependencies to Python path
Only add pythonfutures on Python 2. The concurrent.futures module is
part of the standard library on Python 3.
2018-10-14 16:39:01 +02:00
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
Augusto F. Hack
0868aef516 added type check for g:ycm_filetype_blacklist 2018-09-09 11:00:16 -03: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