Commit Graph

125 Commits

Author SHA1 Message Date
Ben Jackson
24f1f9c900 Support FixIt commands across buffers
We simply apply the changes to each file in turn. The existing replacement
logic is unchanged, except that it now no longer implicitly assumes we are
talking about the current buffer.

If a buffer is not visible for the requested file name, we open it in
a horizontal split, make the edits, then hide the window. Because this
can cause UI flickering, and leave hidden, modified buffers around, we
issue a warning to the user stating the number of files for which we are
going to do this. We pop up the quickfix list at the end of applying
the edits to allow the user to see what we changed.

If the user opts to abort due to, say, the file being open in another
window, we simply raise an error and give up, as undoing the changes
is too complex to do programatically, but trivial to do manually in such
a rare case.
2016-02-21 22:02:33 +00:00
Ben Jackson
d9fef6be14 Remove knowlegde from YCM about subcommand names
Now 'GoTo' and 'FixIt' commands don't need to start with those
prefixes. For 'FixIt' we can detect the response type by looking for
the 'fixits' entry in the response.

For 'GoTo' this is a touch harder, as there is no completely obvious
way to tell. However it is unique in this respect, so we can simply
fall back to it.

Completers returning other types of response are not supported by
this client.
2016-02-21 22:02:33 +00:00
micbou
4835b49a89 Remove interpreter line from Python sources 2016-02-05 16:24:03 +01:00
Spencer G. Jones
c2d473c4ba Add missing implementation on OmniCompletionRequest
OmniCompletionRequest is missing the RawResponse method, so any attempt to call
it calls the base class method instead. However, since the data structures of
this class and base class are different, this causes an error.
2016-01-16 11:36:58 -07:00
Francisco Lopes
9fdd465c26 Allows empty insertion text.
This is useful for hints for example, whose purpose is information
display solely.
2016-01-12 21:48:06 -02:00
Ben Jackson
134b06b65e Fix GoTo lists arriving at the wrong column.
Vim's QuickFix lists require 1-based columns, which is what is returned
from ycmd's commands.

 As noted in the comments, the Vim documentation for setqflist is
somewhat vague about this "byte offset", but it is confirmed to mean
"1-based column number" both in testing and in :help getqflist.
2016-01-04 23:04:13 +00:00
micbou
37f3f1530e Handle scalar response from subcommands
When the ycmd server returns a scalar (boolean, number, string, etc.)
from a subcommand, print it to the user.
2015-11-29 20:03:02 +01:00
micbou
13aeaa37a8 Handle boolean responses from ycmd
Fix ServerReady, ServerRunning, and ServerTerminated subcommands from
C♯ completer.
2015-11-28 16:48:24 +01:00
Ben Jackson
958d8f1eb5 Support subcommands which return detailed info
We display the detailed info text in the preview window. Vim's preview window is
designed to display actual files, not scratch data. Our approach is to open a
temporary file, even though that file is never written. This way, all of Vim's
existing settings for the preview window (and people's configured mappings) just
work. This is also consistent with showing the documentation in the preview
window during completion.

Other plugins have more complicated functions for this (such as eclim), or
Scratch.vim, but this approach is simple and doesn't require external
dependencies or additional settings.

Tests:

This required fixing a sort-of-bug in which the mock'd Vim module was always
only set once, and could not be changed outside of the module which created it.
This meant that it wasn't easy to have arbitrary tests, because it was dependent
on the order in which the tests execute as to whether the return from
MockVimModule() was actually the one in use.

The solution was to make the mock'd vim module a singleton, and use mock's
patch decorator to assign new MagicMock() instances to those methods in the vim
module which a particular test is interested in.
2015-09-20 21:30:23 +01:00
Spencer G. Jones
bb21150798 Fix merge test failure 2015-09-13 08:57:09 -06:00
Spencer G. Jones
2a41101955 Merge remote-tracking branch 'origin/master' into CsAddImport 2015-09-13 08:49:28 -06:00
Homu
a4f7d02a3b Auto merge of #1676 - micbou:fix-it-chunks-sorting, r=Valloric
Correct FixIt chunks sorting

While playing with FixIts in C++, I found the following issue. When fixing the third line in the code:
```cpp
template<int Value> struct CT { template<typename> struct Inner; };

CT<10 >> 2> ct; // expected-warning{{require parentheses}}
```
the following result is obtained:
```cpp
CT<1(0 >> 2)> ct; // expected-warning{{require parentheses}}
```
which is obviously wrong.

The issue is YouCompleteMe does not replace the chunks in the right order. It starts by adding the closing parenthesis, add one to the delta and inserts the opening parenthesis in the wrong place cause of the delta.

We actually use the expression `str(line) + ',' + str(column)` to sort the chunks by line then column whereas it should simply be `(line, column)`.

This PR fixes this issue, adds two tests which are failing in the current version, refactors the `_HandleFixitResponse` function and cleans up code.
2015-09-13 13:48:54 +09:00
Ben Jackson
5cfd6376c6 Show docs from clang completer in preview window
We add the detailed_info (which is the function definiton)
followed by the brief comment
2015-09-12 20:51:04 +01:00
micbou
33316d8bf8 Refactor _HandleFixitResponse function 2015-09-12 18:13:54 +02:00
Spencer G. Jones
9f134c4dd0 To determine which completion prompted CompleteDone, look at the new variable if vim is recent enough. 2015-09-09 08:27:15 -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
Ben Jackson
258951ece4 If errors are returned in addition to completion suggestions, print them 2015-08-17 01:13:20 +01:00
Ben Jackson
98c4d712b4 YouCompleteMe client support for FixIt subcommands 2015-08-05 22:09:07 +01:00
Strahinja Val Markovic
9de61988ac Fix bad formatting for YcmCompleter message
Fixes #1522
2015-06-30 14:24:05 -07:00
Strahinja Val Markovic
ecb4252322 Minor formatting fixes 2015-06-30 13:52:47 -07:00
Andrea Cedraro
3dd24201f3 Revert "Revert "Check the server end point for available completer""
This reverts commit f5e2fc6958.
2015-06-15 16:08:56 +02:00
Strahinja Val Markovic
f5e2fc6958 Revert "Check the server end point for available completer"
This reverts commit d7684470a2.

Fixes #1529
2015-06-11 12:37:40 -07:00
Andrea Cedraro
d7684470a2 Check the server end point for available completer
Previously we were checking if the `hook.py` file existed for the given
filetype. ycmd has an endpoint for checking if given a filetype a
semantic completer is available. To avoid redundant requests we cache
those requests for every filetype. A semantic engine cannot be added
*after* the ycmd server is started so to avoid redundant requests we
cache those requests for every filetype and we clear the cache at server
setup, in this way if we issue a `YcmRestartServer` command the server
will be setup again and if a semantic completer is available we can use
it. Should fix #1284.
2015-06-09 13:09:25 +02:00
Strahinja Val Markovic
a70bf21d29 Updating to latest ycmd
This required changing the HMAC calculation logic.
2015-04-17 15:01:29 -07:00
Ben Jackon
2215bcdeb5 Support completer commands that return text …
This is required to allow the ycmd GetType and GetParent subcommands to echo
their reults in vim. The apporach is to display any text returned from a
subcommand in the 'message' property assuming that the command is not a known
'GoTo' command.
2015-03-19 13:31:24 +00:00
Strahinja Val Markovic
2fafab88c4 Ignoring the new "already being parsed" message
This exception comes from ycmd and is not something the user can do
anything about, so let's rather not show it.
2014-12-10 13:46:10 -08:00
Strahinja Val Markovic
c032cf30c0 Removing default server_location. 2014-08-22 11:25:58 -07:00
Strahinja Val Markovic
0cdb588207 Updating to latest ycmd
Diagnostic & completion 'kind' changed in the REST API.
2014-06-03 14:49:53 -07:00
Strahinja Val Markovic
e9a318fc7c Update to latest ycmd
Upstream completions API changed.
2014-06-02 15:15:45 -07:00
Strahinja Val Markovic
09d4723fcc Updating to latest ycmd
Top-level 'filetypes' property not needed in request data anymore.
2014-05-29 10:42:46 -07:00
Strahinja Val Markovic
5d647fec99 Removing erroneous whitespace 2014-05-28 10:20:54 -07:00
Strahinja Val Markovic
6fa49582ed Fix missing param in OmniCompletionRequest 2014-05-28 00:05:50 -07:00
Strahinja Val Markovic
9100044afc Refactored completion request creation
- OmniCompleter is now more similar to other Completers.
- CompletionRequest doesn't store start_column anymore.
- Calling BuildRequestData only once per request.
2014-05-27 17:38:34 -07:00
Strahinja Val Markovic
4cf9cfcdff Updating to latest ycmd
Since ycmd doesn't need 'query', 'start_column' and 'line_value' params, we
don't send them anymore.
2014-05-27 14:30:22 -07:00
Strahinja Val Markovic
a69bbb3009 Updating code to work with new ycmd location 2014-05-13 13:09:19 -07:00
Strahinja Val Markovic
d56ec1ea7a ycmd's JSON interface now uses 1-based indices
This makes far more sense because editors manipulate user-level errors/warnings
on a 1-based system, not a 0-based one.
2014-05-09 15:57:04 -07:00
Strahinja Val Markovic
9691bd9236 Encoding the x-ycm-hmac header value as base64.
We need to respect RFC 5987.
2014-05-09 10:37:20 -07:00
Strahinja Val Markovic
e965e02847 Client/server communication now uses HMAC for auth
This is to prevent a convoluted exploit that can trigger remote code execution.
2014-04-25 11:07:08 -07:00
Strahinja Val Markovic
9cf566bd8f Renamed GoToDefinitionElseDeclaration to GoTo
The old name still works for the sake of backwards compatibility.
2014-03-21 11:34:00 -07:00
Strahinja Val Markovic
2f051ee9f1 YCM client now sends utf-8 encoded JSON.
Previously, we'd just use json.dumps() to dump out JSON. By default,
ensure_ascii is set to true and non-ASCII chars are encoded as \uXXXX.

Problems seem to happen with other text in the data then not being utf8. I'm not
sure why, still can't repro. This should go away now that we explicitly build a
unicode string which we then encode as utf8.

Hopefully fixes #821.
2014-03-19 13:16:49 -07:00
Strahinja Val Markovic
7a4f5a4a53 Minor var naming changes 2014-03-19 10:27:34 -07:00
Strahinja Val Markovic
18be5c254a Increasing worker thread count to 30
If it takes a while to compile the user's C++ file, the YCM client/server may
run out of threads. Vim gets laggy then.

This is a stopgap measure until I think of something better.
2014-02-07 12:46:45 -08:00
Strahinja Val Markovic
433b3b64f0 Decoding completion strings to utf8 for Vim
Fixes #761
Fixes #775
2014-01-15 11:25:57 -08:00
Strahinja Val Markovic
b1bba2e201 Changing copyright headers from me to Google
When I initially released this project, I released it under my own copyright. I
have since then worked on it in my 20% time at Google (and want to continue
doing this) and my life becomes much simpler if the copyright is Google's.

From the perspective of how this project is run and managed, **NOTHING**
changes. YCM is not a Google product, merely a project run by someone who just
happens to work for Google.

Please note that the license of the project is **NOT** changing.

People sending in future pull requests will have to sign the Google
[CLA](https://developers.google.com/open-source/cla/individual) (you can sign
online at the bottom of that page) before those pull requests could be merged
in. People who sent in pull requests that were merged in the past will get an
email from me asking them to sign the CLA as well.
2014-01-13 11:08:43 -08:00
Strahinja Val Markovic
209d22cfdb DiagnosticInterface now uses server diag objects 2014-01-06 15:24:06 -08:00
Strahinja Val Markovic
3ed8d9883c Diagnostic ranges now exposed to server clients
Still haven't used them in the Vim client though, but will soon.
2014-01-06 15:24:06 -08:00
Strahinja Val Markovic
6c01881e1a Replaced Syntastic support with YCM-native code
Currently, the only supported Syntastic features are the error signs in the
gutter. Other features will be added in the future.
2014-01-06 15:24:05 -08:00
Strahinja Val Markovic
b1d71bbb91 Better handling of unknown extra conf files
Previously, we'd implicitly turn off future notices about unknown extra conf
files if we already raised one exception about it. This breaks when the user
ends up not receiving the "unknown extra conf, load?" message.

Now we only turn off the notice as a result of the user saying "don't load this"
so that if the first request fails to reach them, they'll get a second (and
third etc) request about it.

Fixes #615
2013-12-21 11:19:39 -08:00
Strahinja Val Markovic
cf6211055e Removing the server_idle_suicide_seconds option
This option existed so that the user can tweak it if they found the default idle
timeout too short, for instance if they leave their machine on over the weekend.

This use case is now covered by the new YcmdKeepalive system that pings ycmd
every 10 minutes as long as Vim is running. This prevents ycmd shutting down if
one leaves their Vim instance alone for a long time.

Thus the old option is useless now; ycmd now shuts down after 3 hours of
inactivity, which should only ever happen when its corresponding Vim instance
has shut down abnormally.
2013-11-20 12:33:57 -08:00
Strahinja Val Markovic
7bfb4c3402 Use a thread pool that doesn't join workers
By default, a ThreadPoolExecutor will wait at Python interpreter shutdown for
all the threads to stop by themselves before letting the interpreter shut down.

We don't want that for the network requests thread pool, it causes a shutdown
latency if there are outstanding requests. Killing the threads in our pool is
perfectly safe so we can avoid the latency by introducing an
UnsafeThreadPoolExecutor.
2013-10-30 18:08:35 -07:00
Strahinja Val Markovic
6e782508b3 Now possible to sent Vim data to FlagsForFile func
Fixes #612.
2013-10-26 16:22:43 -07:00
Strahinja Val Markovic
acae8e4e9d Tweaked the request retries logic.
We now send more retry requests that are less spaced apart.
2013-10-17 14:45:53 -07:00
Strahinja Val Markovic
40464f6e0d Resolving issues with event requests timing out
It appears that the issue comes from sending a None timeout to Requests. It
seems it's a bug in Requests/urllib3. So we just pick an arbitrary long timeout
of 30s as the default.
2013-10-17 14:21:37 -07:00
Strahinja Val Markovic
bc607724f0 Ensuring ident completion works always
A bug turned it off when omni completion was available.

Fixes #583.
2013-10-14 13:29:28 -07:00
Strahinja Val Markovic
c3fcaf2b29 Strict 0.5s time budget for completion requests
Vim still loves to block the main GUI thread on occasion when asking for
completions... to counteract this stupidity, we enforce a hard budget of 0.5s
for all completion requests. If the server doesn't respond by then (it should,
unless something really bad happened), we give up.
2013-10-14 11:08:15 -07:00
Strahinja Val Markovic
a04ae37ead Client & server threads increased from 4 to 10 2013-10-11 20:12:04 -07:00
Strahinja Val Markovic
7afd76b4d4 Better url joining in base_request 2013-10-08 20:49:00 -07:00
Strahinja Val Markovic
3d55748400 Correctly handling ycm_extra_conf files now
The user is asked about loading unknown extra conf files, as they were before.
2013-10-08 16:21:43 -07:00
Strahinja Val Markovic
c7be1f1b47 Omni completion works again 2013-10-07 15:47:48 -07:00
Strahinja Val Markovic
4b73739b09 Removing some obsolete todos 2013-10-07 14:21:46 -07:00
Strahinja Val Markovic
ff7fa74fc9 <c-space> works again (forces semantic completion) 2013-10-07 13:09:34 -07:00
Strahinja Val Markovic
a9d7105e1b YCM now working on new buffers with ft set
We used to demand a name be set for the buffer.

Fixes #568.
2013-10-07 11:03:30 -07:00
Strahinja Val Markovic
afa1afc49b Handling no diagnostic data from event response 2013-10-07 11:03:29 -07:00
Strahinja Val Markovic
c274b7d4f8 Fixing the diagnostic-related race conditions
Now, every FileReadyToParse event returns diagnostics, if any. This is instead
of the previous system where the diagnostics were being fetched in a different
request (this caused race conditions).
2013-10-07 11:03:29 -07:00
Strahinja Val Markovic
b9bb788a2a Diagnostics work again... somewhat.
There appear to be timing issues for the diag requests. Somehow, we're sending
out-of-date diagnostics and then not updating the UI when things change.

That needs to be fixed.
2013-10-07 11:03:29 -07:00
Strahinja Val Markovic
7248979bb4 We now handle the starting FileReadyToParse event
The problem was that when you start vim like "vim foo.cc", the FileReadyToParse
event is sent to the server before it's actually started up. Basically, a race
condition.

We _really_ don't want to miss that event. For C++ files, it tells the server to
start compiling the file.

So now PostDataToHandlerAsync in BaseRequest will retry the request 3 times
(with exponential backoff) before failing, thus giving the server time to boot.
2013-10-07 11:03:29 -07:00
Strahinja Val Markovic
9742302cbd 'get_completions' handler is now 'completions' 2013-10-07 11:03:28 -07:00
Strahinja Val Markovic
9d0a6c96d7 Event and completion request are now async
This results in a much snappier Vim.
2013-10-07 11:03:28 -07:00
Strahinja Val Markovic
4a95c2fc7c GoTo commands for clang completer work again 2013-10-07 11:03:27 -07:00
Strahinja Val Markovic
fe0c0a1607 GoTo commands work again 2013-10-07 11:03:27 -07:00
Strahinja Val Markovic
10469d318d Passing user options to server now 2013-10-07 11:03:27 -07:00
Strahinja Val Markovic
387621d957 Moving SendCommandRequest into appropriate module 2013-10-07 11:03:27 -07:00
Strahinja Val Markovic
9a4707f2c6 Ignoring failed event notifications
These happen rarely and are not a big deal when they do. We still log them to
the Vim message area, but we don't annoy the user with the default, in-your-face
Python traceback.
2013-10-07 11:03:26 -07:00
Strahinja Val Markovic
17716ff51f Whitespace fix 2013-10-07 11:03:26 -07:00
Strahinja Val Markovic
1730660555 A (barely) working version of ycmd + client
Still a lot of work to do.
2013-10-07 11:03:26 -07:00