Commit Graph

627 Commits

Author SHA1 Message Date
Kenny Kaye
163238992c Document YcmGetErrorCount and YcmGetWarningCount functions 2015-12-05 09:12:28 -08:00
Kenny Kaye
dafc36ba37 Expose functions to get error and warning counts 2015-12-04 14:45:11 -08: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
Homu
2de2f0df8d Auto merge of #1760 - micbou:ycm-toggle-logs, r=Valloric
Introducing :YcmToggleLogs command

Two approaches were proposed in PR #1753:
- open the stdout and stderr logfiles in Vim windows or close them if already opened: `:YcmToggleLogs`;
- open one of the logfiles in the preview window by specifying it as an argument in the command: `:YcmShowLog <stdout|stderr>`.

This PR merges both approaches by adding an optional argument (`Stdout` or `Stderr`) to the first approach. When no argument is given, both logfiles are opened (or closed if already opened).

With this approach, we cannot use the preview window because only one such window is allowed by Vim. So, we simulate it by adding properties specific to the preview window (horizontal split, height, etc.)

Since they are multiple ways to open a file in Vim, I added a generic function `OpenFilename` for this. It makes easy to customize the way logfiles are opened and could be useful for new features.

Tests were a pain to add and I am not sure of the way I implemented them. If someone could review them. There is some refactoring of the Vim mock.

I updated the documentation and the contribution guidelines. I added a new instruction when creating an issue: adding the output of the `:YcmDebugInfo` command. We often ask it in the issues.

I suggest fetching the `ycm-toggle-logs` branch of my repository to test yourself this command.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/1760)
<!-- Reviewable:end -->
2015-11-17 12:29:56 +09:00
micbou
6f36c3ff82 Improve :YcmToggleLogs behavior
If already opened logfiles are not visible (hidden buffers or in another
tab), close them and open new ones. It fixes the issue where the command
seems to do nothing even though it actually close the non-visible logfiles.
2015-11-11 14:32:01 +01:00
micbou
2eb75ced81 Update buffers-related tests
Mock buffers as a list of buffers where each buffer is represented
as a dictionary containing its filename, its number, and optionally
its associated window.
Test buffer visibility instead of existence.
Mock Vim wipeout command.
Refactor Vim mocks.
2015-11-11 14:18:26 +01:00
Ben Jackson
90dc6fdae5 Correct import of argparse 2015-11-08 23:09:41 +00:00
Ben Jackson
0639200153 Run tests on OS X
We import the scripts from ycmd with a couple of modifications:
 - don't set YCM_CORES=1 as we didn't before, and this makes the build a lot faster
 - don't install gcc-4.8 as we didn't before
 - install argparse as it is not available in python2.6
2015-11-08 22:07:45 +00:00
micbou
cbe3e04745 Add :YcmToggleLogs command 2015-11-08 18:43:52 +01:00
micbou
f23cbae2a8 Add tests for Vim file and buffer operations
Refactor Vim mocking.
2015-11-08 18:43:52 +01:00
micbou
186aa6b671 Remove g:ycm_server_use_vim_stdout option
This option does not work like expected. Logs are not written to the
console. It also makes the ycmd server unresponsive on Windows.
2015-10-27 18:19:22 +01:00
Davit Samvelyan
cb3325970e Refactoring 2015-10-14 11:37:33 +04:00
Davit Samvelyan
a0495a994e Fix for rare crash when trying to jump to file which has .swp 2015-10-13 18:46:20 +04:00
micbou
87854f0245 Move PathToPythonInterpreter function to YCM
Create a module for paths.
2015-10-09 18:53:24 +02: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
8c17995bee Correct FixIt chunks sorting 2015-09-12 18:14:06 +02:00
micbou
17f5f20cd6 Add chunks sorting tests 2015-09-12 18:14:05 +02:00
micbou
2c72a3c598 Clean code in vimsupport tests 2015-09-12 18:14:04 +02:00
micbou
33316d8bf8 Refactor _HandleFixitResponse function 2015-09-12 18:13:54 +02:00
Spencer G. Jones
28e318c0bb fixup! To determine which completion prompted CompleteDone, look at the new variable if vim is recent enough. 2015-09-10 09:18:48 -06:00
Spencer G. Jones
af4aaa1d17 fixup! To determine which completion prompted CompleteDone, look at the new variable if vim is recent enough. 2015-09-09 09:08:41 -06: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
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
Spencer G. Jones
7e9333a9c2 VimVersionAtLeast was not "at least" for minor/major version differences 2015-08-28 08:26:04 -06:00
Ben Jackson
fa32819d4f Pass cwd to completer for filename completions 2015-08-26 23:41:40 +01: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
micbou
0fd842a29e Set stdin to PIPE on Windows only when necessary
Executing the check_core_version.py script with SafePopen and stdin to
PIPE raises an error in Vim on Windows. Since the stdin option is only
useful when starting the ycmd server, it is only set in this case.
2015-07-02 20:47:13 +02:00
Strahinja Val Markovic
8505544d23 Deleting obsolete code 2015-07-02 08:38:27 -07: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
micbou
69eee2097f Redraw the screen before displaying a message
This avoids the infamous "Press ENTER or type command to continue"
prompt when editing a new C-family file.
2015-06-20 05:57:01 +02:00
Andrea Cedraro
fbdf7cc85e Reverse if logic in UpdateDiagnosticInterface 2015-06-15 16:08:56 +02: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
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
77947accf3 Disable completion if any of current filetypes is disable
Fixes #1531
2015-06-12 13:04:03 +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
Sidney San Martín
0e9324d012 Fix spurious warning about missing newline at EOF
C requires a newline at the end of any file, and clang may warn if it's
missing. Vim always saves one to disk, and we should mimic this.
2015-04-15 00:38:05 -07:00
Andrea Cedraro
3c63d22c59 Add new-or-existing-tab as ycm_goto_buffer_command method
resolves #1398
2015-03-26 12:10:46 +01: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
74668373f8 Updating to latest ycmd 2015-03-06 17:07:58 -08:00
Strahinja Val Markovic
4436d515d3 Updating to latest ycmd 2015-01-30 10:21:35 -08:00