Commit Graph

652 Commits

Author SHA1 Message Date
micbou
ef49f3e052 Fix diagnostic highlighting at line ending
When columns are clamped to not be past the contents of the line for
highlighting diagnostics, we need to account for the column end not
being included in the diagnostic range.
2016-08-18 21:21:10 +02:00
micbou
d3916a8752 Extract keywords from whole PreProc syntax group
Reorder syntax groups to follow documentation order.
2016-08-09 11:59:35 +02:00
micbou
75d41d1137 Improve extraction of syntax keywords
Use the following strategy to extract identifiers from syntax
highlighting:
 - ignore match and region: they mostly contain arguments,
   syntax groups and regular expressions;
 - ignore "nextgroup=" if first word and subsequent arguments
   "skipempty", "skipwhite", and "skipnl";
 - ignore "contained" argument if first word;
 - add remaining words to the list of identifiers.
Fix a bug where the word "match" was extracted while not being a keyword
of the syntax language.
2016-08-06 13:39:06 +02:00
micbou
f14485acb9 Rewrite syntax tests
Use matchers from hamcrest instead of eq_ assertions in syntax tests
to get more detailed assertion errors when tests are failing.
2016-08-06 01:12:59 +02:00
micbou
7b2155ab64 Refactor tests using a server instance
Create a Server_test class for tests that need a server instance.
2016-07-23 11:21:38 +02:00
micbou
630b85ad01 Use shutdown request to stop server
Use shutdown request to stop ycmd server in a portable way.
2016-07-23 11:21:20 +02:00
micbou
899746d51c Convert Vim buffers to bytes in ReplaceChunk 2016-07-14 02:39:33 +02:00
micbou
a986b3ed0e Update ReplaceChunk tests
Do not convert strings to bytes but instead use plain strings to mimic
Vim buffers returning a list of byte objects on Python 2 and unicode
objects on Python 3.
2016-07-14 00:46:30 +02:00
Ben Jackson
cfd4bbd531 Support selecting from the list of FixIts when multiple are supplied 2016-07-11 21:52:41 +01: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
Homu
e0f2da0885 Auto merge of #2160 - micbou:open-file-encoding, r=Valloric
[READY] Fix LookupError exception when opening a file

Fixes #2159.

I think the issue is caused by `locale.getpreferredencoding()` returning an empty string on some configurations (especially on OS X with Python 2). This is [the value used by default when no encoding is specified](https://docs.python.org/2/library/io.html?highlight=open#io.open). The same error is raised if we do:
```python
open( 'some_file', encoding = '' )
```

For references, similar issues: https://github.com/Valloric/ycmd/issues/395, https://github.com/Valloric/ycmd/issues/419

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/2160)
<!-- Reviewable:end -->
2016-05-11 02:01:22 +09:00
micbou
b0786d5c4f Fix LookupError exception when opening a file
Open the file in binary mode in CheckFilename function.
Use ReadFile helper in syntax_parse tests.
2016-05-10 16:30:04 +02:00
Ben Jackson
e73426187d Add tests for omni completer GetCompletions 2016-05-08 15:47:58 +01:00
Ben Jackson
4d7b386a37 Fix a number of multi-byte errors and tracebacks
- Correct FixIts when there are unicode characters
- Fix errors in CompleteDone handler
- Fix tracebacks when omnifunc returns unicode chars
2016-05-08 15:32:36 +01:00
micbou
b923431d7d Avoid evaluating Vim globals in Python
On Python 3, evaluating a Vim expression will raise a unicode exception
if it contains an invalid sequence of bytes for the current encoding.
We can't really do anything about it because this is the way Vim and
Python 3 interact. However, we can prevent this situation to occur by
not evaluating Vim data that we have no control over: in particular,
the Vim globals. This is done by:
 - adding one by one the YCM default options instead of extending the
   Vim globals with them;
 - only evaluating the Vim global variable names (and not their values)
   when building the YCM options for the ycmd server.
2016-05-06 20:14:10 +02:00
micbou
b440f682a8 Add error messages when ycmd crashed
Display an error message to the user depending on the status code
returned by the ycmd server.
Remove ycm_core checks in plugin/youcompleteme.vim. These checks are
now done by the ycmd server.
Do not start a separate process to check the core version but rely on
ycmd returning a specific exit code. This slightly improves the Vim
startup time.
2016-05-02 23:08:32 +02:00
Val Markovic
8fe90b43c4 Starting ycmd with Python used to build it
Note: depends on Valloric/ycmd#466 being merged and the ycmd submodule
ref then being updated.

Fixes #2136
2016-04-27 19:42:00 -07:00
micbou
638550384e Update PostComplete tests
Move with-statement patch as decorator when possible.
Use single quote everywhere instead of double quote (for consistency).
Remove empty lines.
2016-04-07 00:42:43 +02:00
micbou
4b9e16f14d Fix PostComplete test
ReturnEmptyIfPendingMatches_OldVim test was identical to
ReturnEmptyIfPendingMatches_NewVim.
2016-04-07 00:42:43 +02:00
Andrea Cedraro
9e6645f515 Rename ycmd python option
- Rename ycm_path_to_python_interpreter to ycm_ycmd_python_interpreter
- Keep ycm_path_to_python_interpreter backward compatible
2016-03-26 19:15:08 +01:00
Ben Jackson
953885c449 Fix traceback when a syntax file has unicode characters
vim.eval returns a str() object on py2, but our internal strings are all unicode().
We use vimsupport.VimExpressionToPythonType to wrap the conversion complexities.
2016-03-10 21:28:42 +00:00
micbou
d59dfb0a7e Do not send request if server is down
Do not send an "event_notification" request in OnFileReadyToParse
function if server process is terminated. Otherwise, it blocks Vim
for one second or results in a traceback each time the InsertLeave,
CursorMoved, CursorHold, and BufferVisit events are triggered.
2016-03-09 16:53:20 +01:00
Ben Jackson
edd2bdbe0f Update flake8 config 2016-03-06 17:39:55 +00:00
micbou
f6d5f68d6b Catch ReadTimeout exception on requests 2016-03-05 22:34:45 +01:00
Val Markovic
0bcecb14d8 Fixing conversion bug in VimExpressionToPythonType
Bug was that objects other than strings/bytes were being converted to
strings. Also added tests.
2016-03-05 10:16:08 -08:00
Val Markovic
74f5e5ef34 Using non-emacs version of python coding line 2016-03-02 18:12:38 -08:00
Val Markovic
80631b1aaf Enforcing unicode in more vimsupport functions 2016-03-01 19:30:02 -08:00
Val Markovic
c91130f280 Not depending on exception internals
We used to read the `message` attribute; that breaks on py3. The
standard idiom is to just use `str( exception )` to get the message.
2016-03-01 19:30:02 -08:00
Val Markovic
0ed1096040 Support multiline exception message
Also stopped adding the "ycmd exception:" prefix to error messages
because it lies; some exceptions hitting this may not come from ycmd.
2016-03-01 19:29:21 -08:00
micbou
f981370965 Fix CheckFilename test on Windows and Py2
On Windows and Python 2, the full exception message from IOError
in CheckFilename will contain the filepath formatted as a unicode
string. Since the filepath is already added in the RuntimeError
message, use the strerror attribute to only display the error.
2016-02-29 20:06:01 +01:00
micbou
fae95812dc Simplify YouCompleteMe test
Add missing python-future boilerplate.
2016-02-29 20:06:01 +01:00
micbou
b78c403cfe Clean up YCM object in PostComplete tests
Move PostComplete tests inside a class that defines setUp and tearDown
methods. Clean YCM object in tearDown method. This fixes the error
"OSError: [WinError 6] The handle is invalid" on Windows with
Python 3.5.
2016-02-29 20:06:01 +01:00
Val Markovic
eb8a24f23d Addressing review comments 2016-02-29 10:26:50 -08:00
Val Markovic
1c65c96e65 Fixing bad comparison causing ToggleLogs to fail
`is` in Python checks for identity, not equality.
2016-02-28 20:24:53 -08:00
Val Markovic
be1bb3617d Minor tweaks 2016-02-28 19:23:40 -08:00
Val Markovic
8c0192ecf7 Can now select python3 for running ycmd 2016-02-28 19:23:40 -08:00
Val Markovic
ba6c6182ed Consistent handling of ServerError exceptions
Previously we used the super-evil 'except Exception' clauses that would
catch everything and turn debugging into a sanity-questioning exercise.
2016-02-28 19:23:40 -08:00
Val Markovic
43b2dd44f2 Ensuring vimsupport only returns unicode text
Python 3 is much stricter around mixing bytes with unicode (and by
"stricter," I mean it doesn't allow it at all) so we're making
vimsupport only return `unicode` objects (`str` on py3). The idea is
that YCM (and ycmd) internals only ever deal with unicode.
2016-02-28 19:23:40 -08:00
Val Markovic
123c5c4acb Fixing ycmd startup under py3
Some syntax rules are different for py3 plus the standard bytes vs
unicode nonsense.
2016-02-28 14:41:09 -08:00
Val Markovic
92346d2bcc Import order fixes for py3
The import machinery works differently in py3, so some massaging is in
order.
2016-02-28 14:39:55 -08:00
Val Markovic
1e72f4d421 Making it clearer an exception came from ycmd
Makes debugging easier when you know where the error lies.
2016-02-28 14:38:23 -08:00
Val Markovic
1941d8bfb2 Fixing issues with bytes vs unicode for hmac 2016-02-27 17:38:38 -08:00
Val Markovic
4e82409cc1 Futurize pass + manual fixes 2016-02-27 16:12:44 -08:00
Homu
cb8607796e Auto merge of #2004 - Valloric:new-omni, r=micbou
[READY] Updating to latest ycmd

This includes the using the new API for OmniCompleter.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.svg" height="40" alt="Review on Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/2004)
<!-- Reviewable:end -->
2016-02-27 08:28:18 +09:00
micbou
298c318bc7 Add test to check if ycm_core is not imported 2016-02-25 02:17:57 +01:00
Val Markovic
fd0c2cc1d8 Updating to latest ycmd
This includes the using the new API for OmniCompleter.
2016-02-24 17:10:13 -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
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
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
micbou
4835b49a89 Remove interpreter line from Python sources 2016-02-05 16:24:03 +01:00
Homu
1201115141 Auto merge of #1927 - micbou:event-notification-test, r=Valloric
[READY] Fix issue in EventNotification tests

While I was reviewing PR #1905, I found an issue with the `EventNotification` tests. It's easy to reproduce. You just need to comment [this line in `python/ycm/youcompleteme.py`](https://github.com/Valloric/YouCompleteMe/blob/master/python/ycm/youcompleteme.py#L508) and run the tests. With this change, the `EventNotification` tests should fail since the second call of `ValidateParseRequest` re-raises the warning. However, tests are still passing because `assert_has_calls` does not check if a call was not made. For example, if `functionA` is called twice, both `assert_has_calls( [ functionA ] )` and `assert_has_calls( [ functionA, functionA ] )` are successful.

To fix this, we just need to check the number of calls using `call_count`. This is done by creating a subclass of `MagicMock` implementing the `assert_has_exact_calls` method and using it in tests.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/1927)
<!-- Reviewable:end -->
2016-01-25 08:26:15 +09:00
Homu
8d5f164feb Auto merge of #1896 - micbou:path-to-python-interpreter, r=Valloric
[READY] Implement new strategy to find the Python interpreter path

See discussion in issue #1891 for details.

Implement a new strategy to find the Python interpreter path:
  - if specified, use `g:ycm_path_to_python_interpreter` option.
  - on UNIX platforms, use `sys.executable` as the path to Python interpreter;
  - on Windows, deduce it from `os.__file__` path (it should always be in the parent folder).

In all cases, check the version (2.6 or 2.7) of the Python interpreter path by running it.

This PR may break things. It needs thorough testing.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/1896)
<!-- Reviewable:end -->
2016-01-25 08:24:34 +09:00
micbou
a0943d5d31 Fall back to Python search in PATH 2016-01-23 16:59:13 +01:00
micbou
c92b4ac0ff Fix issue in EventNotification tests
assert_has_calls is not enough to check if a call didn't raise a
warning. We also need to check the number of calls. This is done by
creating a subclass of MagicMock implementing the
assert_has_exact_calls method.
2016-01-21 03:05:15 +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
Homu
ea3e207643 Auto merge of #1899 - oblitum:empty-insertion-text, r=oblitum
Allows empty insertion text.

This is useful for hints for example, whose purpose is information
display solely.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/1899)
<!-- Reviewable:end -->
2016-01-13 11:24:41 +09: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
Spencer G. Jones
1f868a8b47 fixup! Don't cache invalid completer check results 2016-01-12 15:15:29 -07:00
micbou
9a27c990db Fix typo in test 2016-01-12 22:51:15 +01:00
micbou
1cdbe4a770 Add python3 failing tests 2016-01-12 22:48:48 +01:00
micbou
a80846e35d Check Python interpreter pathname
Rename CheckPythonVersion to IsPythonVersionCorrect.
In embedders, sys.executable may contain a Vim path instead of a Python
one. To avoid starting a Vim instance in this case, we check that given
path ends with a Python 2.6 or 2.7 name using a regex.
Add tests for this regex.
2016-01-12 22:36:31 +01:00
Spencer G. Jones
e57178da00 Don't cache invalid completer check results
If the check for available completers isn't run because the server isn't
alive, or the check request erred or times out, don't cache the result. Only
cache valid returns.
2016-01-12 11:58:18 -07:00
micbou
c7e32b3600 Implement new strategy to find Python path 2016-01-12 01:56:29 +01:00
Homu
f8b3d6643c Auto merge of #1875 - micbou:server-crash-message, r=puremourning
[READY] Update notifications when ycmd server crashed

Instead of printing the last 30 lines of the `stderr` logfile if the server crashed, we tell the user to run the `:YcmToggleLogs stderr` command to check the logs.

Remove `SERVER_CRASH_MESSAGE_SAME_STDERR` message because we are always using the `stderr` logfile since PR #1753. Also, console ouput cannot be used to see the logs.

Simplify `_NotifyUserIfServerCrashed` method by using `CheckFilename` function from `vimsupport` module.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/1875)
<!-- Reviewable:end -->
2016-01-12 05:15:22 +09: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
7fda494026 Add quotes in notifications
Add quotes for Vim commands and options in notifications.
2016-01-03 12:13:00 +01:00
micbou
da095cb93b Update notifications when ycmd server crashed
Tell the user to run the YcmToggleLogs command if the server crashed.
2016-01-02 21:16:00 +01:00
micbou
f015d518a3 Fix traceback when v:completed_item is empty
Check if the Vim variable v:completed_item is not empty before
accessing one of its keys. Prevent a traceback when the ycmd server
crashed.
2015-12-27 18:46:05 +01:00
Ben Jackson
0b07b7467d Add tests for YouCompleteMe.ValidateParseRequest
Most of the code is mocking boilerplate but it shows that the behaviour is as
defined in the comments.
2015-12-24 21:06:44 +00:00
Ben Jackson
6029a672ee Prevent postcomplete_tests.py from leaving mock object lying around
Previously, running postcomplete_tests.py could lead to MagicMock objects being
left around within the ycm modules. This lead to random test failures in other
modules.

Further, by using mock.patch appropriately, tests withing postcomplete_tests.py
no longer rely on mocking performed by previous tests (and can be successfully
run individually)
2015-12-21 19:38:56 +00:00
Ben Jackson
861546fac0 Display errors raised by OnFileReadyToParse in non-diagnostics filetypes 2015-12-20 17:27:17 +00:00
Homu
14083d939d Auto merge of #1821 - micbou:ycm-issue-1818, r=vheon
Set buffer filetypes for UltiSnips

Currently, only `all` snippets are displayed by YCM because UltiSnips is called without setting the buffer filetypes. See issue #1818.

This is fixed by using UltiSnips methods `reset_buffer_filetypes` and `add_buffer_filetypes`.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/1821)
<!-- Reviewable:end -->
2015-12-11 02:55:11 +09:00
micbou
aa73ea0175 Set buffer filetypes for UltiSnips
This fixes #1818.
2015-12-10 00:20:25 +01:00
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
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
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
Strahinja Val Markovic
ba6e1408fd Updating to latest ycmd 2015-01-22 10:14:28 -08: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
def392d24c Fix Vim E885: not possible to change sign
Clang will sometimes give a diagnostic for line 0, and Vim borks on
placing signs for line 0.
2014-10-29 10:16:38 -07:00
Strahinja Val Markovic
fe24f02005 Minor refactoring 2014-10-29 10:02:41 -07:00
Strahinja Val Markovic
ecd2041d9b Updating to latest ycmd
Also required an ABI version bump (some internal names were changed).
2014-10-13 15:14:56 -07:00
Strahinja Val Markovic
33b5b1eb02 Minor refactoring & stylistic changes. 2014-09-19 12:30:15 -07:00
Stanislav Seletskiy
3fcc63127f
Fix handling of signs placed by other plugins
It appears to address numerous amount of issues, including: #812, #801, #887.

Proposed solution uses dummy sign which is placed before updating
diagnostic signs and unplaced afterwards, which eliminates any
flickering. Also, it not just unplace all, it unplaces only that marks
that are changed, so performance should not be an issue in case of many
diagnostic messages.

It's common solution that can be found in some vim plugins that manage
signatures.

Signed-off-by: Stanislav Seletskiy <s.seletskiy@gmail.com>
2014-09-19 03:38:10 +07:00
Strahinja Val Markovic
24bbcf8811 Fix KeyError on no 'no_proxy' env var 2014-09-11 15:19:26 -07:00
Matthias Bilger
d3adb3faf1 Append to no_proxy instead of overwrite
Overwriting no_proxy may cause some trouble for other plugins using network in environments with proxy exceptions, e.g. vim-fugitive
2014-09-11 07:22:27 +02:00
Strahinja Val Markovic
feca403431 Now extracting PHP functions.
Needed special support because of 'contained' syntax arg.

Fixes #1143
Related #1058
2014-09-02 10:53:38 -07:00
Strahinja Val Markovic
15d305ab11 'Function' syntax group now correctly configured 2014-09-02 10:34:26 -07:00
Strahinja Val Markovic
2a704bc668 Custom identifier support now done.
This commit is the YCM-client part of the support. The ycmd support is
already done.

We now need per-language identifier regexes in ycmd (see
identifier_utils.py). There's some for HTML, CSS and the generic regex
that was used for everything until now.  Pull requests welcome for other
languages.

Fixes #86.
2014-08-28 11:39:10 -07:00
Strahinja Val Markovic
57b1ae129c Added a unicode test for OverlapLength() 2014-08-28 11:39:10 -07:00
Strahinja Val Markovic
c032cf30c0 Removing default server_location. 2014-08-22 11:25:58 -07:00
Strahinja Val Markovic
32e3494d6e Handling os.getcwd() throwing an exception.
This can happen if the CWD has been deleted.

Fixes #1129
2014-08-20 13:40:17 -07:00
Strahinja Val Markovic
a5b750703f Comment update 2014-08-19 13:59:33 -07:00
Strahinja Val Markovic
f1ebf51fcb Fix traceback on quote in filename
Fixes #1109
2014-07-31 10:30:03 -07:00
Val Markovic
fd324cbcbb Merge pull request #1070 from evansb/master
Fix unicode-character filename bug.
2014-07-21 15:31:45 -07:00
Evan Sebastian
d18d515b29 Fix unicode-character filename bug.
Issued here https://github.com/Valloric/YouCompleteMe/issues/1069
To reproduce:
1. Create any file with unicode character on its filename, e.g `Ω.c`
2. Open the file and start adding codes until >5 lines (i.e ycm start compiling)
3. YCM will crash due to unicode encoding error. See issue referenced above for complete log.
2014-07-07 22:52:17 +07:00
Alexandre Fonseca
09379b3ff6 Allow '*' in ycm_filetype_specific_completion_to_disable.
I love YCM's auto popup with keyword completion when power typing but
would rather not have semantic completion activate unless I really want
it to (most semantic completers are somewhat slow and sometimes end up
breaking my flow). When in API exploration mode, I don't mind having
to press C-Space to force completion and wait a bit more.

Unless I'm mistaken, the current code does not allow wildcards in the
specification of filetypes on which to disable automatic semantic
completion. This change allows the use of '*' to disable automatic
semantic completion in all files.
2014-06-30 15:36:37 +02:00
Strahinja Val Markovic
6cd929c829 Further support for diag line_num < 1
Fixes #1028
2014-06-09 10:18:03 -07:00
Strahinja Val Markovic
afbc7869a7 Fix off-by-one error with location list diags 2014-06-09 10:04:07 -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
748afecc4a Handle libclang diags for line_num 0
Fixes #978
2014-05-29 13:25:43 -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
666cf3859a Better detection of shortmess 'c' availability
Also noting that the annoying messages during completion go away with Vim
7.3.314.

Related to #642.
2014-05-28 15:48:49 -07:00
Strahinja Val Markovic
8615e408b4 Updating to latest ycmd 2014-05-28 11:24:33 -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
876eaf9c33 OmniCompleter requests now have buffer data
RequestWrap needs buffer data to produce computed properties.
2014-05-27 15:34:46 -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
3d733dca2d :YcmCompleter<TAB> now won't print traceback
If there's no semantic completer set for the current filetype,
:YcmCompleter<TAB> would print an ugly traceback. Ugh.

Fixes #989.
2014-05-22 14:12:51 -07:00
Jan Vcelak
5916226f06 use IPv4 to connect to ycmd 2014-05-21 22:40:47 +02:00
David\ Beitey
3bef7977a9 Enable Function syntax for keyword seeding 2014-05-21 13:33:45 +10:00
Strahinja Val Markovic
ec6966236c GoTo commands now work when spaces in filenames
Fixes #977
2014-05-19 12:37:30 -07:00
Strahinja Val Markovic
68f3577b87 Faster drawing of red diagnostic underlines
The new version of the regex executes faster.

Fixes #968.
2014-05-19 11:10:03 -07:00
Strahinja Val Markovic
d7195f6f19 Fixing race condition on server crash
Crash handling code tried to read stderr log file, but the file can be deleted
by the server befor we get to look at it. In such a case, we post a different
error message (without the log output).

Point is we do our best to get the error output if the user doesn't have
g:ycm_server_keep_logfiles set. If we can't get the logfile, oh well. We tell
the user to set that flag if they care.

Fixes #974.
2014-05-16 19:26:46 -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
abfba7a1aa Moved ycmd-related files to third_party/ycmd
This is in preparation of splitting ycmd into a separate project.
2014-05-12 17:00:43 -07:00
Strahinja Val Markovic
7eaafd7ff8 Using OmniSharp from new directory 2014-05-12 16:30:54 -07:00
Strahinja Val Markovic
ea8ef9c34a Moved OmniSharpServer to third_party folder 2014-05-12 16:14:29 -07:00
Strahinja Val Markovic
1ead914c4e Fixing OmniCompleter to use 1-based start_column
Fixes #963.
2014-05-12 12:54: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
4529bda5c2 Remove unused import 2014-05-09 12:36:36 -07:00
Strahinja Val Markovic
8fd6296f49 Refactored cs_completer tests some more
Common server-wait code is in a helper func now.
2014-05-09 12:19:22 -07:00
Strahinja Val Markovic
52fdf2d09f Formatting fixes 2014-05-09 12:08:29 -07:00
Strahinja Val Markovic
a4da9ee686 Refactoring tests to use new helper methods
Plus minor formatting fixes.
2014-05-09 12:06:56 -07:00
Strahinja Val Markovic
72d91957fc Formatting fixes 2014-05-09 12:04:15 -07:00
Val Markovic
7aa68d93b6 Merge pull request #956 from mispencer/CsharpErrorDisplay
Support for diagnostic for C#
2014-05-09 12:01:43 -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
ec65950a9b Fixing tests
Tests read the default hmac_secret from default_settings.json, and that value is
read as a unicode object by the json parser, not str.
2014-05-09 10:22:00 -07:00
Strahinja Val Markovic
8e40315258 Helper test func for stopping OmniSharp server. 2014-05-08 15:41:07 -07:00
Spencer G. Jones
465019b197 Support for SyntaxErrors in CSharp completer 2014-05-08 15:40:50 -06:00
Strahinja Val Markovic
a1feadece0 indentation fix 2014-05-05 11:11:57 -07:00
Strahinja Val Markovic
ccf0a2ed4d More secure comparison of HMAC strings
To avoid timing attacks. The implementation of SecureCompareStrings is pulled
directly from python 3.4 sources.
2014-05-05 10:35:31 -07:00
Strahinja Val Markovic
b56858d2b0 Error handler now also sets HMAC header. 2014-04-25 12:03:39 -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
479ad62555 Prevent setsid() failure from taking down ycmd 2014-04-10 13:02:49 -07:00
Strahinja Val Markovic
e17be2f81c Revert "Don't pass extra include path to libclang"
This reverts commit 7bdff8941c.
2014-04-02 15:41:48 -07:00
Val Markovic
f054fcfc0a Merge pull request #910 from nickhutchinson/fix-libclang-includes
Fix libclang's #include search path
2014-04-01 21:16:09 -07:00
Marc Burns
6df96fcccf Use OnWindows from utils instead of ad-hoc platform check. 2014-04-01 20:29:20 -04:00
Marc Burns
8f116b849a Detach from controlling terminal to avoid receiving SIGINT. 2014-04-01 04:18:22 -04:00
Spencer G. Jones
439450d3bd CSharp GoTo was off by one column and line 2014-03-31 08:54:46 -06:00
Nicholas Hutchinson
7bdff8941c Don't pass extra include path to libclang 2014-03-27 08:07:56 +00:00
Val Markovic
136b80cd88 Merge pull request #903 from Valloric/watchdog-fix
ycmd watchog timer now wiser about machine sleep
2014-03-26 12:52:56 -07:00
Val Markovic
9d388ef4b3 Merge pull request #845 from davits/master
Added options to choose GoTo commands buffer...
2014-03-24 12:59:35 -07:00
Davit Samvelyan
b4b94429dd reverted back to the GetBufferOption 2014-03-23 12:33:27 +04:00
Davit Samvelyan
b9109af709 Added check for Vim 'hidden' option when trying to open result in the same buffer 2014-03-22 14:24:16 +04:00
Strahinja Val Markovic
90e097efa4 Implementing the new GoToImprecise command
Same as GoTo, but trades correctness for speed. See the docs for details.
2014-03-21 12:37:01 -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
4adf71969d ycmd watchog timer now wiser about machine sleep
We now make sure we don't terminate ycmd if we skipped a watchdog wakeup
time. If we skipped a check, that means the machine probably went to sleep and
the client might still actually be up. In such cases, we give it one more wait
interval to contact us before we die.
2014-03-20 15:44:35 -07:00
Spencer G. Jones
81973caf05 Call OmniSharpServer correctly in Cygwin
Cygwin should not call OmniSharpServer with mono
Update OmniSharpServer submodule for new client path mode parameter
Pass client path mode to OmniSharpServer on run
2014-03-20 08:40:43 -06:00
Strahinja Val Markovic
bf0a499093 Fixing more unicode-related issues.
This is getting really tedious really fast.
2014-03-19 15:13:35 -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
Val Markovic
321355b041 Merge pull request #860 from aslater/master
Revised fix for ycmd terminate race condition
2014-03-05 17:02:19 -08:00